ScanSkill

docker stats

You can use docker stats OR docker container stats to display a live data stream of a running container(s) resource usage statistics.

Syntax

$ 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

Examples

  • Display stats of all the containers
$ 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:

  • CPU stats: It is the percentage(%) of total host capacity.
  • Memory stats: It is the percentage of the host’s CPU and memory the container is using.
  • Block I/O stats: Amount of data the container has read to and written from block devices on the host machine.
  • Network I/O stats: The amount of data the container has been sent and received over its network interface. Received(RX) and Transmitted(TX)
  • PIDs: Number of processes of threads the container has created.
  • Display stats of specific containe
$ 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.