Docker container monitoring using “Docker stats”


Along with orchestration and security, monitoring is another major challenge faced by organizations that have adopted containerization/Docker technologies. This is very critical in production environments, where you need to closely monitor how your microservices are performing and whats happening inside the Docker containers. In this article we will explain how to monitor docker containers using “docker stats” .

Docker Stats

The “docker stats” command allows you to live stream a container’s runtime metrics. The metrics include CPU usage, Memory usage, Network IO, Disk IO .
“docker stats” command returns data stream for running containers. To limit data to one or more specific containers, specify a list of container names or ids separated by a space. You can specify a stopped container but stopped containers do not return any data.


Sample Usage of Docker stats

Formatting “docker stats” output

Docker stats has “–format” option, which enabled us to define the way metrics printed to console. We will define templates in Go format and Valid placeholders for the Go template are listed below:

Valid placeholders for the Go template are 

Placeholder Description
.Container Container name or ID (user input)
.Name Container name
.ID Container ID
.CPUPerc CPU percentage
.MemUsage Memory usage
.NetIO Network IO
.BlockIO Block IO
.MemPerc Memory percentage (Not available on Windows)
.PIDs Number of PIDs (Not available on Windows)

Sample Inputs and Outputs using Templates


In this article we have explained how to monitor docker container CPU, memory and  disk IO metrics using “docker stats” . Please find more detailed explanation at official website here

One thought on “Docker container monitoring using “Docker stats”

Leave a Reply

Your email address will not be published. Required fields are marked *