How to Use Docker Stats to Monitor Container Resource Usage

docker statscontainer resource usagedocker monitoringdocker cpu memorydocker network io
Published·Modified·

The docker stats command displays real-time resource usage statistics for containers. To limit the data to one or more specific containers, separate their IDs with spaces. You can also specify a stopped container, but it will not return any data.

Usage

Simply enter docker stats to display resource usage for all running containers, resulting in output similar to the following screenshot.

The meaning of each column is 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 limit allowed
  • MEM %: Percentage of memory used by the container
  • NET I/O: Amount of data received and sent by the container through network interfaces
  • BLOCK I/O: Amount of data read from and written to block devices on the host by the container
  • PIDS: Number of processes or threads created by the container

You can also specify one or more container IDs or names with docker stats, 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, the command defaults to viewing all running containers. You can also specify a stopped container, but it will not return any data.

Conclusion

The docker stats command also supports formatting the output. For more usage instructions, refer to the official documentation: docker stats