title: Docker with node bcrypt — invalid ELF header
body: <p>I've tried every solution from <a href="https://stackoverflow.com/questions/31604334/elf-header-or-installation-issue-with-bcrypt-in-docker-container">this post</a> and <a href="https://stackoverflow.com/questions/32105251/bcrypt-invalid-elf-header-with-docker-and-sails-js">this post</a></p>
  
  <p>I'm not finding a solution to get rid of the following error when running <code>docker-compose up</code>:</p>
  
  <pre><code>module.js:598
    return process.dlopen(module, path._makeLong(filename));
                   ^
  
  Error: /code/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
  </code></pre>
  
  <p>Here's my latest attempt docker-compose.yml</p>
  
  <pre><code>version: "2"
  
  services:
    app:
      build: ./client
      ports:
        - "3000:3000"
      links:
        - auth
      volumes:
        - ./client:/code
    auth:
      build: ./auth-service
      ports:
        - "3002:3002"
      links:
        - db
      volumes:
        - ./auth-service:/code
    db:
      ...
  </code></pre>
  
  <p>And my auth service Dockerfile:</p>
  
  <pre><code>FROM node:7.7.1
  
  EXPOSE 3002
  
  WORKDIR /code
  
  COPY package.json /code
  
  RUN npm install
  
  COPY . /code
  
  CMD npm start
  </code></pre>
  
  <p>After trying each of the solution from the above two links, I rebuild the containers and it always results in the same error. </p>
  
  <p>Also worth noting, the service runs fine locally, when I don't use docker. </p>
  
  <p>How do I get docker to work with bcrypt?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I was able to get it working by doing the following:</p>
  
  <ol>
  <li>finding the id of the container: <code>docker ps</code></li>
  <li>accessing the container: <code>docker exec -t -i containerId /bin/bash</code></li>
  <li>installing bcrypt: <code>npm install bcrypt</code></li>
  </ol>
  
  <p>This isn't ideal for portability </p>