FROM node:carbon
RUN npm install nodemon -g
WORKDIR /app
COPY . /app
RUN npm installEXPOSE 3030
CMD [ "npm","start" ]
CMD [ "npm" , "run" ,"dev" ]
This looks like you are copying the node_modules from your local, which is probably not Linux.
Add a .dockerignore excluding node_modules
Feel free to reopen, if issue persists.
Hello, I'm had the same problem :(
I have the same error.
I have node version v12.13.1
bcrypt version: "3.0.7"
Dockerfile:
FROM node:12.13.1
WORKDIR /server
COPY . .
RUN npm install
EXPOSE 8000
CMD ["npm", "run", "dev"]
docker-compose.yml
version: "3.3"
services:
db:
build: ./db
restart: always
env_file:
- ./.env
ports:
- 3306:3306
networks:
- app_network
server:
depends_on:
- "db" # this is important for sql connection. it has to wait for mysql to establish connection then run this bish
build: .
command: ["npm", "run", "dev"]
restart: always
ports:
- "8000:8000"
volumes:
- type: bind
source: .
target: /server # this name is from dockerfile workdir
networks:
- app_network
networks:
app_network:
volumes:
app_volume:
dockerignore file:
.env
.vscode
did you resolve this issue? @JulianeAlbuquerque @lagmanzaza
I solved it by using this technique https://www.richardkotze.com/top-tips/install-bcrypt-docker-image-exclude-host-node-modules
@lagmanzaza yes thank you! Ive done something but different link. thanks man
The root cause is => Docker Context. Docker context is copying everything from your root folder to destination container working directory.
So your node_modules (& loading mechanism as per your host OS) is also copied to container working directory.
So you have to add a .dockerignore file and add these entries (with any other files that you want to ignore)
And now when you will build your container, it will build everything as per container's OS and you will not get invalid ELF header error
Most helpful comment
This looks like you are copying the
node_modulesfrom your local, which is probably not Linux.Add a
.dockerignoreexcludingnode_modulesFeel free to reopen, if issue persists.