Docker Stats
Docker stats is a built-in command that streams live CPU, memory, network, block I/O, and process counts for running containers. It is useful for quick checks but is not a substitute for monitoring.
Reading the output
docker stats# CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS# payment-api 2.5% 128MiB / 512MiB 25.0% 2MB / 1MB 0B / 0B 14- CPU %: can exceed 100% on multi-core hosts, since 100% equals one full core.
- MEM USAGE / LIMIT: current memory against the container's limit, or host memory if none is set.
- MEM %: usage divided by limit. Near 100% risks an OOM kill (exit code 137).
- NET I/O and BLOCK I/O: cumulative bytes since start.
- PIDS: number of processes, useful for spotting runaway forking.
Useful patterns
docker stats --no-streamdocker stats payment-api postgresdocker stats --no-stream --format "{{.Name}}: CPU={{.CPUPerc}} MEM={{.MemUsage}} ({{.MemPerc}})" # Warn if any container is above 85% memorydocker stats --no-stream --format '{{.Name}} {{.MemPerc}}' | \ awk '{gsub("%","",$2); if ($2 > 85) print "WARNING: " $1 " at " $2 "%"}'Adjust limits live
docker update --memory 1g --memory-swap 1g payment-apidocker update --cpus 2 payment-apistats versus real monitoring
docker stats has no history, alerts, or multi-host view. For production use cAdvisor with Prometheus and Grafana, or your cloud's container monitoring.
TipWatch MEM % first. Alert at about 85% so you can raise limits before the kernel kills the container.
Common MistakeRelying on
docker statsafter an incident. A container that restarted five minutes ago leaves no trace in the current output.
Frequently Asked Questions
Is docker stats a live measurement or an average?
It is a point-in-time reading from cgroup accounting that refreshes continuously, so CPU can look spiky for bursty workloads. It is accurate, but you need your own averaging for capacity planning.
Why isn't docker stats enough for production?
It only shows the present state on one host, with no history or alerting, so past incidents and fleet-wide patterns are invisible. Use cAdvisor with Prometheus or a hosted monitoring service.
Why does CPU % show over 100?
CPU is expressed relative to a single core, so a container using two cores fully shows about 200%.