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
docker ps Command ReferenceReference for docker ps in CI: list running or all containers with -a, -q, --filter, and --format to inspect…
docker inspect Command ReferenceReference for docker inspect in CI: print low-level JSON for containers, images, volumes, and networks, and e…
docker logs Command ReferenceReference for docker logs in CI: fetch container stdout and stderr with --tail, --since, --timestamps, and -f…