Docker processor allocation

I created a container:

docker run -c=20 -i -t  ubuntu:latest /bin/bash

I tried using a flag -cto control CPU usage and maximize it by 50%. When I run md5sum /dev/urandominside the container, it uses 100% CPU in the host machine.

+4
source share
3 answers

The flag -cfor the command docker runchanges the weighting of the container CPU share relative to the weighting of all other running containers.

It does not restrict the use of the CPU container from the host machine.

You can use the flag --cpu-quotato limit CPU usage, for example:

$ docker run -ti  --cpu-quota=50000 ubuntu:latest /bin/bash

--cpu-quotacommonly used with --cpu-period. For more information on the Docker launch control document, see More details:

https://docs.docker.com/reference/run/#runtime-constraints-on-resources

+6

, , .

, .

1024 . , . , 100% CPU, , ( , ).

+6

, , -, , :

https://docs.docker.com/engine/reference/run/#cpu-period-constraint

CPU CFS ( ) 100 . --cpu-period . --cpu- -cpu-quota.

:

$ docker run -it --cpu-period=50000 --cpu-quota=25000 ubuntu:14.04 /bin/bash

1 , , 50% 50 .

:

"" (), "" . ( ), , .

0

Source: https://habr.com/ru/post/1613717/


All Articles