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}}"
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.