Node.js lightweight Docker image including the PM2 runtime for production applications.
This Docker image in association with PM2, increase application uptime, increase performance (spawn multiple processes and load-balance network query without any code change) and allow graceful state change, adapted to production environment.
$ docker pull keymetrics/pm2-docker-alpine
Versions available:
- keymetrics/pm2-docker-alpine:latest with Node.js 6
- keymetrics/pm2-docker-alpine:4 with Node.js 4
- keymetrics/pm2-docker-alpine:0.12 with Node.js 0.12
These images are automatically built from the Docker hub based on this Github repository branch arrangement.
Make sure you declared a process file called process.yml, this file will be started by PM2.
# Get example app
$ git clone https://github.com/keymetrics/pm2-docker-alpine
# Run example app, mounted as a volume
$ docker run -p 80:3000 -v `pwd`/example_app:/app keymetrics/pm2-docker-alpine
For Keymetrics linking you can set the extra env variables:
-e "KEYMETRICS_SECRET=YYY
-e "KEYMETRICS_PUBLIC=XXX"
-e "INSTANCE_NAME=hostname"
Append to pm2-docker CMD directive:
- --json to output logs in JSON
- --format to output logs in key=val style
- --raw to display logs in raw format
$ docker exec -it <container_id> pm2 monit
$ docker exec -it <container_id> pm2 list
$ docker exec -it <container_id> pm2 show <app_name>
$ docker exec -it <container_id> pm2 reload all
Add into your Dockerfile:
RUN pm2 install pm2-auto-pull
Or try it:
$ docker exec -it <container_id> pm2 install pm2-auto-pull
Make sure the .git is present in your application source folder.
MIT