Checking Docker Container Status with Mackerel
Overview
“My Docker container had silently Exited before I knew it!”
This is a Mackerel Agent configuration to prevent exactly that kind of situation.
Installing mackerel-plugin-docker-state
1 | $ sudo mkdir -p /etc/mackerel-agent/conf.d |
Adding the include setting to mackerel-agent.conf
- /etc/mackerel-agent/mackerel-agent.conf
1 | pidfile = "/var/run/mackerel-agent.pid" |
Restarting the Mackerel Agent
1 | $ sudo service mackerel-agent restart |
Checking the graph
After a little while, the graph will appear.
Note: Since this is a graph with only 0 or 1 values, a stacked graph was easier to read.
Note: In the graph above, two containers are running.
Creating a new monitoring rule
Searching for “running” brings it up.
I set it up so that when the 3-minute average drops below 1,
the container is considered stopped (Exited) and a notification is sent.
Wrap-up
This time I happened to have the chance to work on a service that had Mackerel installed.
I was reminded once again that the benefit of using a managed service like Mackerel
is the reduced operational cost: you don’t have to monitor your monitoring server.

