--cpu-count
and --cpu-percent
is for the HyperV isolation on Windows. When you run a Windows container you have two options.
- Using process isolation: You must have the same Windows version in the container than on the host
- Using HyperV isolation: You will have a virtualized environment, so the container is actually a VM which requires some CPUs. I don’t remember the default number of CPUs, but if it is 1 or 2, but you have 12 cores, you may want to use more, so you can set
--cpu-count
.
I haven’t tried it (I don’t use Windows containers) so I am not sure, but I you could probably use --cpu-count=4
and still limit your container to use only one and a half by setting --cpus=2.5
--cpus
is for telling Docker if it can use 1 full CPU core or 1 and a half and so on… It actually means that Docker will use the power of maximum 1 and a half CPU cores and tries to use as many cores as it can evenly. In case of 15 cores (if the application supports it), in theory it could use 10 percent of the 15 cores. --cpu-percent
is probably does the same on windows with the HyperV layer.
If you want to tell Docker which core the container can use, then you have --cpuset-cpus=1,3
. so it would use the first and a third core.
I have a project on GitHub: https://github.com/itsziget/learn-docker
where I tried to demonstrate how --cpus
and --cpuset-cpus
work.
The Dockerfle: https://github.com/itsziget/learn-docker/blob/master/projects/p09/Dockerfile
and the short tutorial: CPU limit test — Learn Docker documentation
This tutorial is for Linux so I didn’t mention --cpu-count
or --cpu-percent
.
So as I see:
-
--cpu-count
is for the HyperV layer on Windows and there is no alternative to it for containers. Maybe some runtimes have their own configurations to do that. -
--cpu-percent
is for the HyperV layer on Windows to do the same as--cpus
for the containers -
--cpuset-cpus
is to tell Docker which available CPU cores can be used by the processes inside the container, but there is no alternative to select CPU cores on Windows for the HyperV layer.
I hope it was clear enough