Unable to assign ram and cores to Windows Container

Hi All,

I’m trying to create a windows server 2022 container (Windows Docker) with 4gb of ram and 2 cores but unfortunately it does not work nor docker stats command displays min/max for memory.

docker run -it --name ws2022 --cpu-count=2 -m 4096m -p 2051:9081 mcr.microsoft.com/windows/server:ltsc2022 cmd.exe

(Even after the run command, application i’m trying to install inside the container fails because there is not enough ram or cores)

When I try to view stats for containers this is the only view I get, a little different to the documentation:

CONTAINER ID NAME CPU % PRIV WORKING SET NET I/O BLOCK I/O

Any suggestions/help are welcome :slight_smile:

Thank you

If that output is empty, it means you don’t have a running container. How did you check the available cores and memory in the container? I tried these commands from command line:

Show Number of processors, available and total physical memory and so on, but not the number of cores

systeminfo

Show the number of cores:

wmic cpu get NumberOfCores,NumberOfLogicalProcessors

When you set the cpu-count to 4, you will get 4 logical processors and 2 cores.
Here is an other command to get the amount of memory

wmic computersystem get totalphysicalmemory

You can also change the isolation mode depending on the version of the host operating system. Using the process isolation the container would be an actual container not a virtual machine, since the default isolation mode is hyperv.

docker run --isolation process -it --name ws2022 --cpu-count=2 -m 4096m -p 2051:9081 mcr.microsoft.com/windows/server:ltsc2022 cmd.exe

This way the cpu count parameter will not matter, since there will be no virtualization. You will see all of the CPUs and set cpu limits if you want to (at least I guess. I never tried it with Windows containers).

Read about the compatibility matrix here to find out if you can use process isolation