Reputation: 1106
I'm a noob with Docker and I keep getting this error for pretty much whatever I place inside my Dockerfile, and I'd like to know how to fix it:
FROM node:12.18.2-alpine
COPY --chown=node:node . .
USER node
CMD [ "node", "server.js" ]
I've simplified my Dockerfile since I still get the same error anyways.
docker-compose.yml file:
version: '3'
services:
sharpimg:
build:
context: .
dockerfile: Dockerfile
image: sharpimg
container_name: sharpcontainer
restart: unless-stopped
env_file: .env
ports:
- "80:3000"
volumes:
- .:/home/sharpimg/app
- node_modules:/home/node/app/node_modules
command: nodemon --ignore './dist/' server.js
volumes:
node_modules:
Versions:
Ubuntu 20
Docker version 19.03.8
docker-compose version 1.26.2
Full error:
$ sudo docker-compose up --build; docker-compose logs
Removing sharpcontainer
Building sharpimg
Step 1/4 : FROM node:12.18.2-alpine
---> 057fa4cc38c2
Step 2/4 : COPY --chown=node:node . .
---> Using cache
---> ec6d6aaf78fe
Step 3/4 : USER node
---> Using cache
---> 7a11c49c015a
Step 4/4 : CMD [ "nodemon", "server.js" ]
---> Using cache
---> e695913b2d66
Successfully built e695913b2d66
Successfully tagged sharpimg:latest
Recreating 6bc5228b5b83_sharpcontainer ... error
ERROR: for 6bc5228b5b83_sharpcontainer Cannot start service sharpimg: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"docker-entrypoint.sh\": executable file not found in $PATH": unknown
ERROR: for sharpimg Cannot start service sharpimg: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"docker-entrypoint.sh\": executable file not found in $PATH": unknown
ERROR: Encountered errors while bringing up the project.
Attaching to sharpcontainer, 6bc5228b5b83_sharpcontainer
I've upgraded docker and docker-compose and I don't even use a docker-entrypoint.sh
file so I'm not really understanding this error. Please help
Upvotes: 1
Views: 9726
Reputation: 1514
The docker-entrypoint.sh
is the entrypoint script for node docker image.
When you changed the user, maybe you lost the $PATH
and therefore the script was not found.
Try to keep the same user, and if doesn't work, maybe when you copy, you override the script?
Please check here how is the suggested usage of node image.
Upvotes: 2