Default CPU share

Hi all,

When I run a container say Ubuntu or HTTPD without configuring --cpu-shares, I thought the default CPU share is set to 1024. However, when I inspect a container with.

docker container inspect container-name | grep -i cpu

The cpushares is actually 0

It’s not until I update with

docker update --cpu-shares 5210 container-name

I can see that cpushare is updated with 5210. I thought it is set 1024 by default?

Hi @minh_duc ,

The 0 value here indicates “use the default as is set by the daemon”; this is currently not configurable, but having a 0 value allows making this possible in future, similar to what’s used for;

      --cpu-rt-period int                     Limit the CPU real-time period in microseconds
      --cpu-rt-runtime int                    Limit the CPU real-time runtime in microseconds

See the documentation here; Docker run reference | Docker Docs

CPU share constraint

By default, all containers get the same proportion of CPU cycles. This proportion can be modified by changing the container’s CPU share weighting relative to the weighting of all other running containers.

To modify the proportion from the default of 1024, use the -c or --cpu-shares flag to set the weighting to 2 or higher. If 0 is set, the system will ignore the value and use the default of 1024 .

More about this concept and details here in this link.

Regards,
Vitor Jr.
KodeKloud Support