Reputation: 531
I made 2 docker images from 2 folder in this repo. The dockerfile was:
FROM node:13-alpine
EXPOSE 5000
RUN mkdir /app
RUN mkdir -p /home/app
COPY . /home/app
RUN npm install
CMD ["npm","run","start"]
But the docker logs showed that the package.json
file was not found and hence the containers closed, I can't even enter the terminal of the containers to see the available files.
The error output is in the below image.
To reproduce the error, clone the repo and run sudo docker-compose -f docker-compose.yaml up
Upvotes: 0
Views: 584
Reputation: 5937
You didn't specify the working directory in your dockerfile and that's why the package.json
cannot be found.
Ref: https://docs.docker.com/engine/reference/builder/#workdir
add WORKDIR before RUN npm install
WORKDIR /home/app
RUN npm install
Upvotes: 1