Monitor All the Things using Docker and Monit

March 16, 2018
docker monitoring

After setting up 329423 services and 823423 containers, you might want to manage your environment in case some service fails. This can be automated restarting, getting notified about failures or a similar thing. Say no more, I’ve created a Dockerfile and image for Monit for this.

Monit is extremely configurable and allows a maximum of flexibility when it comes to monitoring.

Initially, a configuration file is required to get started. To get one, call

docker run \
   -d \
   --name=monit \
   --restart=always \
   --expose 2812 \
   -p \
   --entrypoint monit ps1337/monit-docker -I && \
docker exec -it monit bash -c "cat /etc/monitrc" && \
docker rm -f monit

and save the output to monitrc.

To finally monitor services on a machine, you can use this command:

docker run \
   -d \
   --name=monit \
   --restart=always \
   -v $PWD/monitrc:/etc/monit/monitrc \
   --expose 2812 \
   -p \

This runs Monit on localhost for security reasons - change this if required.

After doing the initial setup, one can start monitoring for example

You can then refer to the Monit manual for information on adding hosts to monitor.

One helpful option to use is exec, which executes shell scripts in case a service fails:

check host yolo with address
  if (failed port 80 protocol http with timeout 15 s) retry 5 then exec "/opt/scripts/ 'FAIL'"

Information Leak in Docker

January 4, 2019
docker vulnerability

Docker Breakout Using X11

May 18, 2018
docker pentesting hacking

Random Note #12354123: Easy Remote Pair Programming Using Docker and Tmux

April 10, 2018
randomnote docker vim tmux shell programming