Viewing Docker Resource Utilisation

Peter Nguyen
Peter Nguyen

Docker resource utilisation can sometimes run wild, and it'd be nice to see what's happening under the hood with the containers we're running. Docker out of the box provides the docker stats command, returning a live data stream for the running containers.

image alt text

By default docker stats will provide some basic fields like container id, name, cpu and memory usage but what if we only want certain fields? We can pass in the ---format option and supply the various formatting placeholders available:

docker stats --all --format "table {{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"
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)

https://docs.docker.com/engine/reference/commandline/stats/