Monitoring Docker Containers: From docker stats to cAdvisor
Three cheap layers of real monitoring: docker ps and stats, log rotation with json-file and max-size, and cAdvisor for live graphs.

Table of contents
A container that is running is not necessarily healthy. Practical monitoring for small stacks breaks down into three cheap layers, each answering a different question.
Layer 1: docker ps and docker stats
docker ps shows the state of every container. If you have defined a healthcheck, the STATUS column shows Up (healthy) or Up (unhealthy) instead of a plain Up, the same thing you see in docker compose ps. docker stats lists live CPU and memory usage per container:
docker stats --no-stream
On a single server run by one person, this one command plus the health column covers a large part of day-to-day monitoring.
Layer 2: log rotation
Docker’s default log driver (json-file) grows without limit and will eventually fill the disk. Capping it is a three-line block:
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
To read the logs: docker compose logs -f --tail=100 app. If a disk has already filled up, see reclaiming disk space from Docker.
Layer 3: cAdvisor for live graphs
To see trends rather than just the current moment, the cAdvisor container publishes CPU, memory, network and disk metrics for every container on a web dashboard and on the standard /metrics endpoint (for Prometheus). It starts with a single command; restrict its port so only you can reach it.
Take healthchecks seriously
All of these layers only work if your services actually have healthchecks. The standard pattern for an HTTP service:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
In words: check every 30 seconds; after 3 consecutive failures the container is marked “unhealthy” and your alert fires. The first 40 seconds after start (start_period) don’t count, so normal start-up hiccups are not reported as failures.
Next steps
Once you have more than one server, cAdvisor + Prometheus + Grafana is the common open-source monitoring combination. To begin with, the three layers in this article are entirely sufficient for a single server.



Comments
No comments yet. For technical questions, include the details (OS version, the exact error and the command you ran) to get a precise answer.