I am new to the docker thing. I build a docker container called: app in which my webapp is running and a mongodb container called: mongo which provides the data for my webapp. I use the docker compose to set both containers up. I have a login screen on my webserver and when i want to log in, my app container crashs. With following error massage:
app | Segmentation fault (core dumped)
app | npm ERR! code ELIFECYCLE
app | npm ERR! errno 139
app | npm ERR! [email protected] start: `NODE_ENV=production node ./bin/www`
app | npm ERR! Exit status 139
app | npm ERR!
app | npm ERR! Failed at the [email protected] start script.
app | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
app |
app | npm ERR! A complete log of this run can be found in:
app | npm ERR! /root/.npm/_logs/2018-08-22T06_49_55_101Z-debug.log
My dockerfile looks like the following:
FROM node:8.11.3-alpine
ARG NPM_TOKEN
WORKDIR /usr/src/app
COPY .npmrc .npmrc
COPY package*.json ./
RUN apk --no-cache add --virtual native-deps \
g++ gcc libgcc libstdc++ linux-headers make python && \
npm install --quiet node-gyp -g &&\
npm install --quiet && \
apk del native-deps
RUN npm install
RUN rm -f .npmrc
COPY . .
EXPOSE 3000
CMD [ "npm", "start"]
and the docker-compose.yml like this:
version: "2"
services:
app:
container_name: app
restart: always
build: .
ports:
- "3000:3000"
links:
- mongo
mongo:
container_name: mongo
image: mongo
volumes:
- ./data:/data/db
ports:
- "27017:27017"
When i only start the mongodb container and the app with the command "NODE_ENV=production node ./bin/www" (without container) then everything is working fine... (I only change the mongo db "host" name when i run the app local or in a container)
I have actually no idea what I am doing, but when I change my dockerfile like this it is working:
FROM node:8.11.3-alpine
ARG NPM_TOKEN
RUN apk update
WORKDIR /usr/src/app
COPY .npmrc .npmrc
COPY package*.json ./
RUN apk --no-cache add --virtual builds-deps build-base python
RUN npm config set python /usr/bin/python
RUN npm i -g npm
RUN npm install
RUN npm rebuild bcrypt --build-from-source
RUN apk del builds-deps
RUN rm -f .npmrc
COPY . .
EXPOSE 3000
CMD [ "npm", "start"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With