I have a stock standard docker desktop set up an Azure VM
It is being used as a build server, I noticed the build process takes 10 times as long as my local PC and after discussing with the developer it was determined that the CPU limits imposed by docker are the cause.
When I run the command wmic cpu get NumberOfLogicalProcessors I get a value of 2, but the VM has 4 processors
I have seen some people suggest I can run the command docker run --cpu-count 4 imagename
But because this is VM scales the number of CPUs based on usage, and the commands are triggered by an automated build system this isnāt feasible
Is there a way I configured docker to just use the maximum number of CPUs at all times?
Docker Desktop is a developer tool, intended for developer desktop PCs. It uses a VM to run most containers, as Docker was developed as a Linux tool.
When running a container in DD on Win, you got two possible constraints: the container itself can be resource limited (not by default) and the VM (by default).
Usually Docker Desktop on Windows uses WSL2, check if you find some DD settings for resources or similar to change VM settings.
While this being true, of course Windows containers do not depend on WSL2.
The output of docker info should tell us how many cpus are detected.
With Linux containers, there is no resource constraint, unless a container is specifically created with cpu/ram constraints. I can only assume that Windows containers behave the same way. Can we borrow your experience here @vrapolinario? :
EDIT : In this post I still assumed the topic was about Linux containers, even though the title clearly contains āWindows containersā, so I deleted this post as well to not confuse others.
I totally missed that. In fact I was sure my comment was right after @bluepuma77 's comment not noticing @meyay ⦠So Iām not sure what I saw. I was possibly lost while switching between topics.
I will reread everything and come back if I can provide actual help
And Iām here again. I turned on my Windows laptop to test my idea. First of all there are two kinds of isolation. āprocessā and āhypervā. By default the hyperv isolation is used. That part of my earlier but aleady deleted post was right. When you use the hyperv isolation, the default number of CPUs is 2. The small hyperv VM under the container gets two CPUs unless you override it with --cpu-count which you also knew already.
I could not find a parameter that changes the default, but when you use process isolation, you get all CPUs without a virtual machine under the container. What I found is that you can change the default isolation in the docker daemon
For Windows containers, you can specify the default container isolation technology to use, using the --exec-opt isolation flag.
The following example makes hyperv the default isolation technology:
dockerd --exec-opt isolation=hyperv
If no isolation value is specified on daemon start, on Windows client, the default is hyperv, and on Windows server, the default is process.
So I thought I could change the daemon config
{
"exec-opt": ["isolation=process"]
}
but it had no effect, so it is possible that it cannot be changed to use process isolation by default unless you are using a Windows server where you wouldnāt use Docker Desktop as it is not supported even if some users managed to run it for a short time until it didnāt work.
Thanks for your research - yes it looks like there is no solution for me - I even asked on Github⦠Docker Desktop developers should really look at this issue because I am sure it is leading to developers thinking Docker is slow
Anyway, in the end I have done as you suggested, recreated the build server as a Windows server OS and it all works as expected (process isolation, full access to CPU and memory) and it is much faster
@rimelek you are correct on your investigation. The option to change the default isolation would be the ideal solution here. I have tested that myself, but for some reason, Docker Desktop keeps removing the daemon configuration (at least in my tests) and bringing back the default isolation to hyperv.
Iām not sure if thereās an option to change the isolation when you build an image. If there is, that would also solve the problemā¦
Yes I looked into that early on in the process - we are using Azure Pipelines which unfortunately provides no way to pass through such arguments without us rewriting a large part of the build scripts