Skip to content
Latchkey

docker stats Command Reference

Show live resource usage of containers.

docker stats displays a live stream of CPU, memory, network, and block I/O for running containers. In CI you almost always add --no-stream to take a single snapshot, since the default streaming output never returns.

Common flags

  • --no-stream - print a single snapshot and exit (essential in CI)
  • -a, --all - include non-running containers
  • --format - Go template output, e.g. "{{.Name}} {{.MemUsage}}"
  • --no-trunc - do not truncate output

Example

shell
docker stats --no-stream --format "{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"

In CI

Use docker stats --no-stream to capture a one-shot resource snapshot when debugging an OOM-killed container or a slow integration run. Without --no-stream the command blocks forever and the step times out.

Key takeaways

  • --no-stream is mandatory in CI; the default streams indefinitely.
  • --format gives scriptable per-container CPU and memory figures.
  • Useful for diagnosing OOM kills and resource-starved test containers.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →