You can use docker stats
OR docker container stats
to display a live data stream of a running container(s) resource usage statistics.
$ docker stats [OPTIONS] [CONTAINER...]
Here,
Options:
--all
, -a
→ Show all containers--format
→ Pretty-print images using a Go template--no-stream
→ Disable streaming stats and only pull the first one--no-trunc
→ No truncation to output$ docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
a3f78cb32a8e hello-world 0.00% 2.137MiB / 3.605GiB 0.06% 0B / 0B 9.95MB / 0B 0
Since I have only one running container, it’s showing one. If you have more it will show all of them.
Note: Here, the key metrics are:
$ docker stats hello-world
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
a3f78cb32a8e hello-world 0.00% 2.137MiB / 3.605GiB 0.06% 0B / 0B 9.95MB / 0B 0
Note: You can use either container name or container ID.