Question: How to monitor a running docker container performance metrics. For example, CPU,memory, I/O and network stats?
The docker stats command can continuously report the basic CPU, memory, network and disk I/O metrics. For example:
# docker stats a3f78cb32a8e 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
Alternatively, you can also run “docker stats” and “docker stats –all” to monitor all running container’s metrics.
In the command output, these are the following key metrics:
1. CPU stats
CPU is reported as % of total host capacity.
2. Memory stats
It is the percentage of the host’s CPU and memory the container is using. If the host is using memory for other processes, your container will run out of memory before it hits the limit reported by the stats command.
3. Block I/O stats
The amount of data the container has read to and written from block devices on the host.
4. Network I/O stats
The amount of data the container has sent and received over its network interface. Displays total bytes received (RX) and transmitted (TX).
They are the number of processes or threads the container has created.