I have a node js application as a docker image when I run a container with node server.js it works fine but when I run it with pm2-runtime server.js didn't work fine, although it is installed and configured well, I tried everything but with no benefit
Asked
Active
Viewed 38 times
0

Sabreen Salama
- 33
- 7
-
[Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) I cannot run your Dockerfile, for example, because `docker build` does not accept PNG files. Can you [edit] your question to include your [mcve] in plain text? – David Maze Jun 23 '23 at 21:30
-
Docker itself takes on a lot of the responsibilities of a process manager; for example it can restart the container if its main process exits. Also see [what is the point of using pm2 and docker together?](https://stackoverflow.com/questions/51191378/what-is-the-point-of-using-pm2-and-docker-together) If `node server.js` works, can you just use that without the pm2 layer? – David Maze Jun 23 '23 at 21:31
-
I want to thank you for your reply, I need pm2 as the customer needs it to work in a cluster mode(active: passive), I solved the issue by running CMD in the docker file to be : ```pm2 start npm -- run start ``` instead of ```pm2-runtime start server.js``` and npm start defined in package.json – Sabreen Salama Jun 24 '23 at 12:39