Skip to content
LatchkeyLatchkey home

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.

Frequently asked questions

docker stats Command Reference?
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.
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.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card