Error while running dockerfile

Asked

Viewed 305 times

1

I own one dockerfile which runs an application in Node.js

FROM node

RUN npm install mongoose

RUN useradd --user-group --create-home --shell /bin/false app &&\
  npm install --global [email protected]

ENV HOME=/home/app

COPY package.json $HOME/library/
RUN chown -R app:app $HOME/*

USER app
WORKDIR $HOME/library
RUN npm install --silent --progress=false

USER root
COPY . $HOME/library
RUN chown -R app:app $HOME/*
USER app

CMD ["npm", "start"]

and a docker-compose.yml

version: '2'
services:
  db:
    image: mongo
    command: "mongod"
    ports:
      - "27018:27018"
  library:
    build:
      context: .
      dockerfile: Dockerfile
    command: node_modules/.bin/nodemon --exec npm start
    environment:
      NODE_ENV: development
    ports:
      - 8080:8080
    volumes:
      - .:/home/app/library
      - /home/app/library/node_modules
    links:
      - db

Then run docker-compose build try to run with docker-compose up

Then the mistake happens:

    > node-rest-auth@ start /home/app/library
> node server.js

/home/app/library/node_modules/bindings/bindings.js:83
        throw e
        ^

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/app/library/node_modules/bcrypt/build/Release/bcrypt_lib.node)
    at Object.Module._extensions..node (module.js:689:18)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at bindings (/home/app/library/node_modules/bindings/bindings.js:76:44)
    at Object.<anonymous> (/home/app/library/node_modules/bcrypt/bcrypt.js:3:35)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/app/library/app/models/user.js:3:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rest-auth@ start: `node server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-rest-auth@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/app/.npm/_logs/2018-02-05T16_21_54_845Z-debug.log
  • @Brunocésar The error continues. I managed to fix the error, I will post here as I got

1 answer

1


After much trying to fix that mistake

The error actually it is quite simple. By doing the COPY . $HOME/library and rotate the docker build . us we send the node_modules along. This makes the settings of npm install sane in fact that of personal machine.

There’s a simple way to solve what is creating (or by adding the node_modules if you already have such a file) .dockerignore where will we go place the node_modules, being like this:

.dockerignore

node_modules

With that we must fix the problem.

Clean up the caches, or excludes all the images(that’s what I did), and then run the docker build . or docker-compose build again, and the mistake will no longer be there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.