Use the following commands to navigate docker, manage containers and images, and run containers.
Information and Stats
sudo docker stats
Shows the stats of running docker containers in a live stream loop. Loop repeats once per second.
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
56f4862b7524 nginx 0.00% 6.512MiB / 3.836GiB 0.17% 862MB / 926MB 35.5MB / 0B 3
c82f4f6ed970 bi_api_container 0.06% 199.7MiB / 3.836GiB 5.08% 34.8MB / 33.2MB 385MB / 15.1MB 21
1d5ff2b5ccd1 bi_jobs_container 0.03% 249.7MiB / 3.836GiB 6.36% 362MB / 121MB 415MB / 188kB 21
855b7d4d3a5c bi_ds_container 0.10% 266.8MiB / 3.836GiB 6.79% 238MB / 373MB 1.8GB / 187MB 21
6efb04c469b0 bi_web_container 0.05% 380.2MiB / 3.836GiB 9.68% 75.9MB / 174MB 973MB / 19.8MB 24
fab7cbf7d24c id_api_container 0.04% 140.1MiB / 3.836GiB 3.57% 132MB / 123MB 296MB / 233kB 20
0daf81ca0079 id_ums_container 0.07% 306.7MiB / 3.836GiB 7.81% 88.8MB / 141MB 446MB / 721kB 23
83959b5c67f6 boldbi_db_1 0.00% 45.57MiB / 3.836GiB 1.16% 532kB / 429kB 674MB / 2.05GB 20
18445d8586ba id_web_container 0.11% 297.8MiB / 3.836GiB 7.58% 87MB / 141MB 508MB / 549kB 23
120800518adf boldbi_adminer_1 0.00% 5.699MiB / 3.836GiB 0.15% 32.6kB / 0B 65.8MB / 0B 1
Options:
sudo docker stats --all
Shows the stats of all docker containers (running or stopped).
sudo docker stats --no-stream
Disables the live streaming and displays the stats one time and stops.
sudo docker stats --format string
Pretty prints the stats using a format string such as JSON or a table. See examples below. Explanation of the syntax {{ . }} can be found on Go websites or others such as https://gobyexample.com/text-templates
sudo docker stats boldbi_adminer_1 --no-stream --format "{{ json . }}"
Prints the stats of the docker container named “boldbi_adminer_1” without streaming and in a JSON string.
{"BlockIO":"65.8MB / 0B","CPUPerc":"0.00%","Container":"boldbi_adminer_1","ID":"120800518adf","MemPerc":"0.15%","MemUsage":"5.699MiB / 3.836GiB","Name":"boldbi_adminer_1","NetIO":"32.7kB / 0B","PIDs":"1"}
sudo docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
Specifies the columns wanted and controls the order of the columns using table formatting.
CONTAINER CPU % MEM USAGE / LIMIT
56f4862b7524 0.00% 6.496MiB / 3.836GiB
c82f4f6ed970 0.04% 199.6MiB / 3.836GiB
1d5ff2b5ccd1 0.03% 249.7MiB / 3.836GiB
855b7d4d3a5c 0.06% 266.1MiB / 3.836GiB
6efb04c469b0 4.21% 380.2MiB / 3.836GiB
fab7cbf7d24c 0.04% 140.2MiB / 3.836GiB
0daf81ca0079 0.06% 306.9MiB / 3.836GiB
83959b5c67f6 0.00% 45.57MiB / 3.836GiB
18445d8586ba 0.04% 297.6MiB / 3.836GiB
120800518adf 0.00% 5.699MiB / 3.836GiB
Leave A Comment?