Docker command is unable to find my configuration file
I have a pm2 Docker image for launching nodeJS process in production. The image can be found here: https://hub.docker.com/r/keymetrics/pm2/~/dockerfile/
Docker launch the command pm2-runtime start pm2.json
and fails as it can't find any /pm2.json
.
However I do have a pm2.json
in the working directory, so why is it looking at the root /
?
I would also like to run the docker images with docker-compose. Is there something to configure in the docker-compose.yml file to look at the working directory ?
When I check the official Dockerfile :
FROM keymetrics/pm2:{{tag}}
# Bundle APP files
COPY src src/
COPY package.json .
COPY pm2.json .
# Install app dependencies
ENV NPM_CONFIG_LOGLEVEL warn
RUN npm install --production
# Show current folder structure in logs
RUN ls -al -R
CMD [ "pm2-runtime", "start", "pm2.json" ]
It is copying the npm2.json
from the directory inside the image. Aren't you missing that part?
The default working directory for running binaries within a container is the root directory (/).
If you want to change it:
docker run
: docker run -w="..."
working_dir
is what you need, see: https://docs.docker.com/compose/compose-file/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.