Getting container resource usage using the stats feature
Docker has a feature to easily get the resource usage for the containers that it manages. The following recipe shows you how to use it.
Getting ready
You will need a Docker host that can be accessed via the Docker client. Also, start a few containers to get some stats.
How to do it...
Follow these steps:
- Run the following command to get stats from one or more containers:
$ docker stats [OPTIONS] [CONTAINERS]
For example, if we have two containers with the names some-mysql and backstabbing_turing, then run the following command to get the stats as shown in the below screenshot:
$ docker stats some-mysql backstabbing_turing

How it works...
The Docker daemon fetches resource information from cgroups
and serves it through the APIs.
See also
Refer to the Docker stats documentation at https://docs.docker.com/engine/reference/commandline/stats/.