docker-container-stats
TLDR
Display a live stream for the statistics of all running containers
Display a live stream of statistics for one or more containers
Change the columns format to display container's CPU usage percentage
Display statistics for all containers (both running and stopped)
Disable streaming stats and only pull the current stats
SYNOPSIS
docker stats [OPTIONS] [CONTAINER...]
docker container stats [OPTIONS] [CONTAINER...]
PARAMETERS
-a, --all
Show all containers (default: only running)
--format string
Pretty-print using a Go template
--no-stream
Disable streaming; show single snapshot
--no-trunc
Do not truncate output
DESCRIPTION
The docker stats (or docker container stats) command displays live, real-time resource usage statistics for Docker containers. It streams metrics including CPU %, memory usage and limit, network I/O, block I/O, and PIDs, updating every second by default. This tool is essential for monitoring container performance, debugging resource bottlenecks, and ensuring efficient resource allocation in production environments.
Without arguments, it shows stats for all running containers. Specify one or more container names or IDs for targeted monitoring. The output is tabular: CONTAINER ID, NAME, CPU % (host CPU utilization), MEM USAGE / LIMIT (e.g., 10.5MiB / 2GiB), MEM %, NET I/O (e.g., 1.2kB / 1kB), BLOCK I/O (e.g., 0B / 4.1kB), and PIDs.
Use --no-stream for a single snapshot. Custom formatting via --format uses Go templates (e.g., '{{.CPUPerc}}%'). It's lightweight, non-interactive, and supports piping to tools like grep or log aggregators. Stats reflect cgroup data, accurate for Linux but approximated on other platforms.
CAVEATS
Streams indefinitely by default (Ctrl+C to stop); stats unavailable or static for stopped/paused containers even with -a; high-frequency updates may impact performance on busy systems.
DEFAULT OUTPUT COLUMNS
CONTAINER ID | NAME | CPU % | MEM USAGE/LIMIT | MEM % | NET I/O | BLOCK I/O | PIDs
EXAMPLE USAGE
docker stats myapp (single container)
docker stats --no-stream $(docker ps -q) (all running, one-shot)
HISTORY
Introduced in Docker 1.5.0 (February 2014) as part of core CLI for container monitoring; evolved with cgroup v2 support in Docker 20.10+.


