View Docker Container Resource Usage with the Docker Stats Command

Publish: 2020-10-26 | Modify: 2020-10-26

The docker stats command displays container resource usage and provides real-time information. To limit the data to one or more specific containers, separate the container IDs with spaces. You can also specify a stopped container, but a stopped container doesn't return any data.

docker stats

Usage

Simply enter docker stats to display resource usage for all running containers. You will see screenshot-like information similar to the following:

docker stats output

The meanings of each column are as follows:

  • CONTAINER ID: Container ID
  • NAME: Container name
  • CPU %: Percentage of host CPU used by the container
  • MEM USAGE / LIMIT: Total memory used by the container and the total memory allowed
  • MEM %: Percentage of memory used by the container
  • NET I/O: Data received and sent by the container through network interfaces
  • BLOCK I/O: Data written to and read from block devices on the host by the container
  • PIDS: Number of processes or threads created by the container

You can also use docker stats with one or more container IDs or names, for example:

# View resource usage for a single container (by ID)
docker stats 7c3e162bef49
# View resource usage for a single container (by name)
docker stats name
# View resource usage for multiple containers
docker stats xxx xxx

If no container ID or name is specified, it defaults to displaying resource usage for all running containers. You can also specify a stopped container, but a stopped container doesn't return any data.

Conclusion

The docker stats command can also format the results. For more information, please refer to the official documentation: docker stats


Comments