How to count the status of Docker container resources?
Before we begin
How do I count the resource information occupied by a container?
Docker provides the stats subcommand to understand the resource usage of the current running container, including: CPU, memory, network IO, disk IO, and so on.
Environment description
Docker 1.10.3 on CentOS 7
This version of Docker is very old and can not be found at present. In addition, Ubuntu Server 16.04 LTS is recommended for Linux host operating system Docker, which can better support advanced features such as overlay2 storage driver.
For instance
1. All container status information is output by default
Docker stats# uses Ctrl + C to exit statistics
two。 Outputs the specified container status information
Docker stats nginx# uses Ctrl + C to exit statistics
3. Or you can output the result only once.
Docker stats-- no-stream nginx command helps docker stats-- helpUsage: docker stats [OPTIONS] [CONTAINER...] Display a live stream of container (s) resource usage statistics-a,-- all Show all containers (default shows just running)-- help Print usage-- no-stream Disable streaming stats and only pull the first result summary
Finally, let's summarize the knowledge points in the article.
Learn about the resource usage of the currently running container through the docker stats subcommand. Output real-time statistics by default and exit using Ctrl + C key. Parameter-no-stream means that real-time statistics are disabled and only the results obtained for the first time are used.
Reference article
Doker&k8s Qun [703906133]