Monique docker?

I'm going to docker. I would like to do something like monit: if the container crashes, restart it. if the memory exceeds a certain limit, restart it. How can I do that?

+3


source to share


2 answers


While the docker-provided container restart feature provides some help, it is not nearly as thorough as monit. I asked around on fig repo https://github.com/docker/fig/issues/464 and it was suggested to use God or Bluepill. I looked to God and it goes a long way to keeping God in the container and for God to control the webapp process for me.



+1


source


You can use the new 1.2 Docker: Container Restart

. It might not be as powerful as monit (I can't tell since I don't know the tool).

You can add a flag --restart=always

in docker run

to tell docker to always restart the container when it crashes.



As for the memory limit case, you can monitor the container from the outside by fetching the logs generated by the monitor inside the container and restarting it docker restart

with a simple script. Or, if you have your own program, you can code it so that it exits with a meaningful exit code when it reaches a memory limit, and restart the container with --restart=on-failure:<number-of-tries>

.

For more information, you can see the Docker 1.2 release note

+3


source







All Articles