Docker Container always stopped and started I am using docker compose to build two containers, one is nodejs with pm2 and another is nginx.
The nginx one runs well but the nodejs with pm2 one keeps restarting: it runs for one second, then stops for ~10 seconds, then starts again and runs for one second, as you can see this is the output of docker ps -a:

I have used docker attach 'ID' but it still restarted.
Using docker logs shows nothing, but jenkins says that pm2 was started successfully:

This is the content of my Dockerfile:
FROM node:8    
MAINTAINER test    
RUN npm install -g pm2

WORKDIR /var/www/marketing    

EXPOSE 80    

RUN npm install    
RUN pm2 start npm -- stage

If any of you could help me, I will update this question if you guys have any request.
Thank you
You should keep at least one service running in foreground to keep the container running, you can do that using ENTRYPOINT or CMD or both. For more info check Dockerfile: ENTRYPOINT vs CMD.

You can also use a docker image for pm2 from docker hub, that will save your time and you can check the Dockerfile for it to see how it is written.
Check the keymetrics/pm2-docker-alpine project, for example.