Docker stats cpu over 100

To explain Docker stats and CPU usage over 100%, we need to understand a few concepts and review an example.

Understanding Docker Stats

Docker stats is a command-line utility that provides real-time information about the resource usage of Docker containers. It provides an overview of CPU, memory, network, and disk I/O usage of running containers.

CPU Usage Percentage Calculation

The CPU usage percentage is calculated based on the overall CPU capacity allocated to the container. By default, Docker assigns a maximum of 1024 units of CPU, representing 100% of a single CPU core, to each container.

The CPU usage percentage measurement is relative to the available capacity assigned to the container. For example, if a container’s CPU usage is reported as 200%, it means it is using the equivalent of two CPU cores.

Example Scenario

Let’s consider an example scenario where we have a Docker container running a CPU-intensive application. The Docker host has a CPU with two cores.

If the Docker container is assigned the maximum CPU capacity of 1024 units (100% of one CPU core) and the CPU usage reported by Docker stats is 200%, it means that the container is using the equivalent of two CPU cores, which matches the available CPU capacity.

However, if the Docker container is assigned a CPU capacity of 2048 units (200% of one CPU core), and the CPU usage reported by Docker stats is again 200%, it means that the container is using the equivalent of four CPU cores (200% of 200%), which exceeds the available CPU capacity. In this case, the CPU usage reported will be over 100%.

Same cateogry post

Leave a comment