monit daemon existence test issue when run in docker container

Issue #533 new
Former user created an issue

Alpine Linux edge/monit 5.20

There appears to be an issue with monit daemon existence testing when running inside docker containers when monit is either the command/entrypoint for the container (runs as PID 1) or is started by an init type process which is the command/entrypoint for the container eg. busybox init. Under these conditions it is not possible to control monit from the command line, eg. "monit status" command reports "monit daemon is not running" when IT IS running, the pid file exists, and the http socket is accessible. It is possible, for instance, to view the status report by using "wget http://127.0.0.1:2812/_status -qO-" on the command line inside the container or with docker exec from outside. There is no problem if you run a shell within a container and start monit manually from the command line.

To be clear:

working with a docker image containing monit with working config...

host>docker run -it <image> /bin/sh cid>monit cid>monit status -> status report listed

host>docker run -dit <image> /sbin/monit -I host>docker exec <cid> monit status -> monit: the monit daemon is not running host>docker exec <cid> wget http://127.0.0.1:2812/_status -qO- -> status reported listed host>docker exec -it <cid> /bin/sh cid>monit status -> monit: the monit daemon is not running cid>wget http://127.0.0.1:2812/_status -qO- -> status reported listed

Although the monit pid file exists in the container, a /proc entry for that pid does not, and the monit process is not listed by ps or top within the container, but is listed with docker top <cid> from outside. This is no doubt due to the way docker runs the initial process when stating a container. Presumably the tests to check if the monit daemon is running rely on the existence of the /proc entry in addition to the pid file.

Comments (0)

  1. Log in to comment