1

I'm creating a docker for the Back-End server, but everything is fine until I create a volumes, so I have my .yml configured docker-compose.yml

version: "3.7"

services:
  my-api: 
    container_name: backend
    build: ./
    command: npm start
    working_dir: /usr/src/my-api
    ports:
      - "3000:3000"
    volumes:
      - ./:/usr/src/my-api

and this is my Dockerfile

FROM node:10

WORKDIR /usr/src/my-api

COPY ./ ./

RUN npm install

CMD ["/bin/bash"]

Considering that I created my .dockerignore

node_modules

From what I have analyzed, the problem is that when creating the volumes, the modules are copied directly and that causes the problem shown below.

Successfully built e1dfb81dd4c4
Successfully tagged facial-api_smart-brain-api:latest
Creating backend ... done
Attaching to backend
backend            |
backend            | > facial-api@1.0.0 start /usr/src/Facial-api
backend            | > nodemon server.js
backend            |
backend            | [nodemon] 1.18.4
backend            | [nodemon] to restart at any time, enter `rs`
backend            | [nodemon] watching: *.*
backend            | [nodemon] starting `node server.js`
backend            | internal/modules/cjs/loader.js:718
backend            |   return process.dlopen(module, path.toNamespacedPath(filename));
backend            |                  ^
backend            |
backend            | Error: /usr/src/Facial-api/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
backend            |     at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
backend            |     at Module.load (internal/modules/cjs/loader.js:599:32)
backend            |     at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
backend            |     at Function.Module._load (internal/modules/cjs/loader.js:530:3)
backend            |     at Module.require (internal/modules/cjs/loader.js:637:17)
backend            |     at require (internal/modules/cjs/helpers.js:20:18)
backend            |     at Object.<anonymous> (/usr/src/Facial-api/node_modules/bcrypt/bcrypt.js:6:16)
backend            |     at Module._compile (internal/modules/cjs/loader.js:689:30)
backend            |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
backend            |     at Module.load (internal/modules/cjs/loader.js:599:32)
backend            | [nodemon] app crashed - waiting for file changes before starting...

Any idea, recommendation to solve it?

C. Marca
  • 23
  • 1
  • 8
  • It is important to mention that the idea is based on correcting something similar to the one presented in [ELF Header or installation issue with bcrypt in Docker container](https://stackoverflow.com/questions/31604334/elf-header-or-installation-issue-with-bcrypt-in-docker-container), but my case is that of volumes – C. Marca Sep 13 '18 at 05:32

1 Answers1

0

There are two possible scenarios,

  1. If you use one platform to install node modules like(Windows/MacOSX), and trying to run with the same node modules without reinstalling it in other platform like(Linux). If in the case try removing node modules in existing platform and "rpm install" the same.
  2. If the node version that you had installed in one platform differs with other, Check this for more details.