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.
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) |