{"id":13491758,"url":"https://github.com/keymetrics/docker-pm2","last_synced_at":"2025-04-04T23:09:32.623Z","repository":{"id":9645819,"uuid":"62876979","full_name":"keymetrics/docker-pm2","owner":"keymetrics","description":"🐳 Official Docker Image for PM2 runtime","archived":false,"fork":false,"pushed_at":"2023-12-13T18:51:12.000Z","size":112,"stargazers_count":474,"open_issues_count":37,"forks_count":60,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-28T22:13:30.763Z","etag":null,"topics":["docker","docker-image","docker-pm2","pm2"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/keymetrics/pm2","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keymetrics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-08T09:27:16.000Z","updated_at":"2025-03-21T19:37:24.000Z","dependencies_parsed_at":"2024-10-31T05:31:51.070Z","dependency_job_id":"6eaf8a9a-4fc9-4a07-874e-b737d46f1e24","html_url":"https://github.com/keymetrics/docker-pm2","commit_stats":{"total_commits":181,"total_committers":9,"mean_commits":20.11111111111111,"dds":0.4419889502762431,"last_synced_commit":"eec68b5068a2d25225cac5f800ec83da56c2d32a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fdocker-pm2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fdocker-pm2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fdocker-pm2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fdocker-pm2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keymetrics","download_url":"https://codeload.github.com/keymetrics/docker-pm2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261612,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","docker-pm2","pm2"],"created_at":"2024-07-31T19:00:59.946Z","updated_at":"2025-04-04T23:09:32.598Z","avatar_url":"https://github.com/keymetrics.png","language":"Dockerfile","funding_links":[],"categories":["Dockerfile"],"sub_categories":[],"readme":"# PM2\n\nProduction ready nodeJS Docker image including the [PM2 runtime](http://pm2.keymetrics.io/).\n\nThe goal of this image is to wrap your applications into a proper Node.js production environment. It solves major issues when running Node.js applications inside a container like:\n\n- Correct PID 1 signals Handling \u0026 Forwarding\n- Graceful application Start and Shutdown\n- Seamless application clustering to increase performance and reliability\n\nFurther than that, using PM2 as a layer between the container and the application brings PM2 features like [application declaration file](http://pm2.keymetrics.io/docs/usage/application-declaration/), [customizable log system](http://pm2.keymetrics.io/docs/usage/log-management/), [source map support](http://pm2.keymetrics.io/docs/usage/source-map-support/) and other great features to manage your Node.js application in production environment.\n\n## Tags available\n\n**Image Name** | **Operating system** | **Dockerfile**\n---|---|---\nkeymetrics/pm2:`latest-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[latest-alpine](tags/latest/alpine/Dockerfile)\nkeymetrics/pm2:`18-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[15-alpine](tags/16/alpine/Dockerfile)\nkeymetrics/pm2:`16-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[15-alpine](tags/16/alpine/Dockerfile)\nkeymetrics/pm2:`15-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[15-alpine](tags/15/alpine/Dockerfile)\nkeymetrics/pm2:`14-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[14-alpine](tags/14/alpine/Dockerfile)\nkeymetrics/pm2:`12-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[12-alpine](tags/12/alpine/Dockerfile)\nkeymetrics/pm2:`10-alpine`|[Alpine](https://www.alpinelinux.org/about/)|[10-alpine](tags/10/alpine/Dockerfile)\n\n**Image Name** | **Operating system** | **Dockerfile**\n---|---|---\nkeymetrics/pm2:`latest-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[latest-buster](tags/latest/buster/Dockerfile)\nkeymetrics/pm2:`18-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[18-buster](tags/18/buster/Dockerfile)\nkeymetrics/pm2:`16-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[16-buster](tags/16/buster/Dockerfile)\nkeymetrics/pm2:`15-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[15-buster](tags/15/buster/Dockerfile)\nkeymetrics/pm2:`14-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[14-buster](tags/14/buster/Dockerfile)\nkeymetrics/pm2:`12-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[12-buster](tags/12/buster/Dockerfile)\nkeymetrics/pm2:`10-buster`|[Debian Buster](https://wiki.debian.org/DebianBuster)|[10-buster](tags/10/buster/Dockerfile)\n\n**Image Name** | **Operating system** | **Dockerfile**\n---|---|---\nkeymetrics/pm2:`latest-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[latest-stretch](tags/latest/stretch/Dockerfile)\nkeymetrics/pm2:`18-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[18-stretch](tags/18/stretch/Dockerfile)\nkeymetrics/pm2:`16-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[16-stretch](tags/16/stretch/Dockerfile)\nkeymetrics/pm2:`15-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[15-stretch](tags/15/stretch/Dockerfile)\nkeymetrics/pm2:`14-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[14-stretch](tags/14/stretch/Dockerfile)\nkeymetrics/pm2:`12-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[12-stretch](tags/12/stretch/Dockerfile)\nkeymetrics/pm2:`10-stretch`|[Debian Stretch](https://wiki.debian.org/DebianStretch)|[10-stretch](tags/10/stretch/Dockerfile)\n\n**Image Name** | **Operating system** | **Dockerfile**\n---|---|---\nkeymetrics/pm2:`latest-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[latest-jessie](tags/latest/jessie/Dockerfile)\nkeymetrics/pm2:`18-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[18-jessie](tags/18/jessie/Dockerfile)\nkeymetrics/pm2:`16-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[16-jessie](tags/16/jessie/Dockerfile)\nkeymetrics/pm2:`15-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[15-jessie](tags/15/jessie/Dockerfile)\nkeymetrics/pm2:`14-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[14-jessie](tags/14/jessie/Dockerfile)\nkeymetrics/pm2:`12-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[12-jessie](tags/12/jessie/Dockerfile)\nkeymetrics/pm2:`10-jessie`|[Debian Jessie](https://wiki.debian.org/DebianJessie)|[10-jessie](tags/10/jessie/Dockerfile)\n\n**Image Name** | **Operating system** | **Dockerfile**\n---|---|---\nkeymetrics/pm2:`latest-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[latest-slim](tags/latest/slim/Dockerfile)\nkeymetrics/pm2:`18-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[18-slim](tags/18/slim/Dockerfile)\nkeymetrics/pm2:`16-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[16-slim](tags/16/slim/Dockerfile)\nkeymetrics/pm2:`15-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[15-slim](tags/15/slim/Dockerfile)\nkeymetrics/pm2:`14-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[14-slim](tags/14/slim/Dockerfile)\nkeymetrics/pm2:`12-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[12-slim](tags/12/slim/Dockerfile)\nkeymetrics/pm2:`10-slim`|[Debian Stretch](https://wiki.debian.org/DebianStretch) (minimal packages)|[10-slim](tags/10/slim/Dockerfile)\n\nYou can find more information about the image variants [here](https://github.com/nodejs/docker-node#image-variants).\n\n\u003e The build process of these images is automatically triggered each time [NodeJS's Docker images](https://hub.docker.com/r/library/node/tags/) are built.\nThe build process of these images is automatically triggered each time [Docker PM2's GitHub repo](https://github.com/keymetrics/docker-pm2) master branch is pushed.\nThe build process of these images is automatically triggered each time [PM2's GitHub repo](https://github.com/Unitech/pm2) master branch is pushed.\n\n## Usage\n\nLet's assume the following folder structure for your project.\n\n```\n`-- your-app-name/\n    |-- src/\n        `-- app.js\n    |-- package.json\n    |-- pm2.json     (we will create this in the following steps)\n    `-- Dockerfile   (we will create this in the following steps)\n```\n\n### Create a pm2 ecosystem file\n\nCreate a new file called `pm2.json` with the following content:\n\n```json\n{\n  \"name\": \"your-app-name\",\n  \"script\": \"src/app.js\",\n  \"instances\": \"2\",\n  \"env\": {\n    \"NODE_ENV\": \"development\"\n  },\n  \"env_production\" : {\n    \"NODE_ENV\": \"production\"\n  }\n}\n```\n\u003e You can choose the name of the `ecosystem` file arbitrarily, but we will assume you called it `pm2.json` in the following steps.\n\nSee the [documentation](http://pm2.keymetrics.io/docs/usage/application-declaration/#generate-configuration) for more information about how to configure the `ecosystem` file.\n\n### Create a Dockerfile file\n\nCreate a new file called `Dockerfile` with the following content:\n\n```dockerfile\nFROM keymetrics/pm2:latest-alpine\n\n# Bundle APP files\nCOPY src src/\nCOPY package.json .\nCOPY pm2.json .\n\n# Install app dependencies\nENV NPM_CONFIG_LOGLEVEL warn\nRUN npm install --production\n\n# Show current folder structure in logs\nRUN ls -al -R\n\nCMD [ \"pm2-runtime\", \"start\", \"pm2.json\" ]\n```\nSee the [documentation](http://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/#usage) for more info about the `pm2-runtime` command.\n\u003cbr\u003eAll options available are listed [here](http://pm2.keymetrics.io/docs/usage/application-declaration/#attributes-available).\n\n### Build and Run your image\nFrom your Node.js app project folder launch those commands:\n\n```bash\n$ docker build -t your-app-name .\n$ docker run your-app-name\n```\n\n## Custom configurations\n\n### Enable git auto-pull\n\nIf you want to [Automatically synchronize your application with git](https://github.com/pm2-hive/pm2-auto-pull) add this into your Dockerfile:\n\n```\nRUN pm2 install pm2-auto-pull\n```\n*Make sure the .git is present in your application source folder.*\n\n### Enable Monitor server\n\nIf you want to [Automatically monitor vital signs of your server](https://github.com/keymetrics/pm2-server-monit) add this into your Dockerfile:\n\n```\nRUN pm2 install pm2-server-monit\n```\n\n### Use Keymetrics.io dashboard\n\n[Keymetrics.io](https://keymetrics.io/) is a monitoring service built on top of PM2 that allows to monitor and manage applications easily (logs, restart, exceptions monitoring, etc...). Once you created a Bucket on Keymetrics you will get a public and a secret key.\n\nTo enable Keymetrics monitoring with pm2-runtime, you can whether use the CLI option –public `XXXX` and –secret `YYYY` or you can pass the environment variables `KEYMETRICS_PUBLIC` and `KEYMETRICS_SECRET`.\n\nFrom your Node.js app project folder launch those commands:\n\n```bash\n$ docker build -t your-app-name .\n$ docker run -e KEYMETRICS_PUBLIC=XXXX -e KEYMETRICS_SECRET=YYYY your-app-name\n```\n\nMake sure that the ports 80 (TCP outbound), 443 (HTTPS outbound) and 43554 (TCP outbound) are allowed on your firewall.\n\nSee the [troubleshooting](http://docs.keymetrics.io/docs/pages/faq-troubleshooting/#troubleshooting-for-keymetrics-pm2) in case you encounter any problem.\n\n### Enabling Graceful Shutdown\n\nWhen the Container receives a shutdown signal, PM2 forwards this signal to your application allowing to close all the database connections, wait that all queries have been processed or that any other final processing has been completed before a successful graceful shutdown.\n\nCatching a shutdown signal is straightforward. You need to add a listener in your Node.js applications and execute anything needed before stopping the app:\n\n```javascript\nprocess.on('SIGINT', function() {\n  db.stop(function(err) {\n    process.exit(err ? 1 : 0);\n  });\n});\n```\nBy default PM2 will wait `1600ms` before sending a final `SIGKILL` signal. You can modify this delay by setting the `kill_timeout` option inside your application configuration file.\n\n### Expose health endpoint\nThe `--web [port]` option allows to expose all vital signs (docker instance + application) via a JSON API.\n\n```\nCMD [\"pm2-runtime\", \"start\", \"pm2.json\", \"--web\"]\n```\nor\n```\nCMD [\"pm2-runtime\", \"start\", \"pm2.json\", \"--web\", \"port\"]\n```\n\n## Useful commands\n\nCommand | Description\n--------|------------\n```$ docker exec -it \u003ccontainer-id\u003e pm2 monit``` | Monitoring CPU/Usage of each process\n```$ docker exec -it \u003ccontainer-id\u003e pm2 list``` | Listing managed processes\n```$ docker exec -it \u003ccontainer-id\u003e pm2 show``` | Get more information about a process\n```$ docker exec -it \u003ccontainer-id\u003e pm2 reload all``` | 0sec downtime reload all applications\n\n## Documentation\n\nThe documentation can be found [here](http://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/).\n\n## Authors\n* **Alexandre Strzelewicz** - [Unitech](https://github.com/Unitech)\n* **Simone Primarosa** - [simonepri](https://github.com/simonepri)\n\nSee also the list of [contributors](https://github.com/keymetrics/docker-pm2/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\nLicense information for the software contained in this image can be found [here](https://github.com/Unitech/pm2/blob/master/GNU-AGPL-3.0.txt) (pm2) and [here](https://github.com/nodejs/node/blob/master/LICENSE) (node).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeymetrics%2Fdocker-pm2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeymetrics%2Fdocker-pm2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeymetrics%2Fdocker-pm2/lists"}