Contents
Docker stats tutorial: Monitor real-time resource usage (--no-stream, --format)
docker stats displays a container's real-time resource usage. For process inspection and debugging, see View logs and debug.
Syntax
docker stats [OPTIONS] [CONTAINER...]
docker top CONTAINER [ps OPTIONS]
Options
| Option | Description |
|---|---|
-a, --all | Show all containers (by default, only running containers are shown) |
--format TEMPLATE | Use a custom template for output; you can use table, table TEMPLATE, json, or a Go template |
--no-stream | Disable streaming and get only the first result |
--no-trunc | Don't truncate the output |
docker top accepts ps options. The examples below use -o to specify which process fields to display.
Examples
Check all containers or specify one container
$ docker stats --no-stream
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
0c009f73010b small 0.00% 716KiB / 64MiB 1.09% 628B / 126B 381kB / 0B 1
f3e514c09baa busy 43.08% 1.289MiB / 1.919GiB 0.07% 796B / 126B 1.83MB / 0B 1
63b9a2f9c63f web 0.00% 4.43MiB / 1.919GiB 0.23% 838B / 126B 8.95MB / 8.19kB 2
35357aad74b1 registry 2.01% 13.19MiB / 1.919GiB 0.67% 3.89MB / 19.6kB 135MB / 3.92MB 5
$ docker stats --no-stream web
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
63b9a2f9c63f web 0.00% 3.812MiB / 1.919GiB 0.19% 838B / 126B 8.95MB / 8.19kB 2
--no-streamgets only the first result and doesn't continuously update the screen.- If you don't specify a container, multiple running containers are listed. Specifying
weblists only that container. MEM USAGE / LIMITshows both usage and the limit. The limit forsmallis64MiB; the other example containers show1.919GiB.NET I/OandBLOCK I/Oshow network and block I/O, respectively.PIDSis the process count.
Output with a table template or JSON
$ docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'
NAME CPU % MEM USAGE / LIMIT
small 0.00% 616KiB / 64MiB
busy 42.14% 936KiB / 1.919GiB
web 0.00% 3.723MiB / 1.919GiB
registry 0.31% 14.1MiB / 1.919GiB
$ docker stats --no-stream --format '{{json .}}' small
{"BlockIO":"381kB / 0B","CPUPerc":"0.00%","Container":"small","ID":"0c009f73010b","MemPerc":"0.79%","MemUsage":"516KiB / 64MiB","Name":"small","NetIO":"698B / 126B","PIDs":"1"}
- The
tabletemplate produces column headers. This example selects only the name, CPU percentage, and memory usage. {{json .}}outputs the specified container's statistics as a single-line JSON object.- Usage varies between samples: both the table and JSON results for
smallshow a64MiBlimit, but the memory usage differs.
Inspect container processes and customize fields
$ docker top web
PID USER TIME COMMAND
2315 root 0:00 nginx: master process nginx -g daemon off;
2351 101 0:00 nginx: worker process
$ docker top web -o pid,user,comm
PID USER COMMAND
2315 root nginx
2351 101 nginx
docker toplists the processes running in a container. By default, the output includes the PID, user, time, and full command.- With custom fields
-o pid,user,comm, the output omits TIME, and COMMAND shows a shorter process name.
Related chapters
- View logs and debug
- docker ps command: List containers
- docker inspect command: View container details
- Container lifecycle
Exercises
Exercise: Query the small container once and display its name and memory usage in a table.
Answer
docker stats --no-stream --format 'table {{.Name}}\t{{.MemUsage}}' small
FAQ
How do I check just one container with docker stats?
Specify the container name after the command, for example, docker stats --no-stream web. The output will include only web.
What does MEM USAGE / LIMIT mean in docker stats?
It shows memory usage and the limit. In the example, small shows 716KiB / 64MiB, so you can see the 64MiB limit directly in the field.
How do I show only PID, USER, and COMMAND with docker top?
Use docker top web -o pid,user,comm. The output will list those three fields.
Updated October 26, 2026