I have the follow structure
[vagrant@localhost]$ ls
api package.json yarn.lock
client favicon.ico
Dockerfile ecosystem.config.js README.md
With follow Dockerfile
FROM keymetrics/pm2-docker-alpine
RUN npm install pm2 -g
ADD . . # COPY HOW CAN I SEE IF WAS COPY
CMD ["pm2-docker", "ecosystem.config.js"]
So my question is.. how to run this image and keep runner with pm2 ?
docker run -d -p 3000:3000 --name backend backend:v3
[vagrant@localhost swarmbot]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f28aa7459527 backend:v3 "pm2-docker ecosys..." 10 minutes ago Exited (1) 9 minutes ago backend
Status Exited .. why?
Anthony Lapenna
Open-source enthusiast
You could have a look at the logs first... It might help you figure out what's the problem:
docker logs backendYou can try to use the following Dockerfile:
FROM keymetrics/pm2-docker-alpine RUN npm install pm2 -g WORKDIR /pm COPY . /pm/ CMD ["pm2-docker", "ecosystem.config.js"]The
WORKDIRinstruction will create a new/pmfolder in the container and set this folder as the working directory for the nextCOPYandCMDcommands, see: docs.docker.com/engine/reference/builderIn the
CMDinstruction, there is no need to specify the path to theecosystem.config.jsfile as it should be copied in the/pmdirectory which is the working directory.Give it a try.