Docker windows container memory limit

做~自己de王妃 提交于 2019-11-28 20:39:54
deafsheep

According to talks on Docker for windows Github issues (https://github.com/moby/moby/issues/31604), when Docker for Windows is run under Windows 10, it is actually using a Hyper-V isolation model (and process model is not accessible in Win 10 scenario).

And in that isolation type, your container is run inside a lightweight VM, which DOES have a default limit, and it is 1 Gb. So if you want to have more memory you should use -m param.

Surprise! Surprise!

I have 32Gb RAM on my host but I can see only 1Gb RAM given to Windows containers:

D:\>systeminfo | findstr "Memory"
Total Physical Memory:     1,023 MB
Available Physical Memory: 634 MB
Virtual Memory: Max Size:  1,023 MB
Virtual Memory: Available: 674 MB
Virtual Memory: In Use:    349 MB

D:\>wmic OS get FreePhysicalMemory /Value
FreePhysicalMemory=648340

D:\>wmic computersystem get TotalPhysicalMemory
TotalPhysicalMemory
1072742400

The same limit on images made from:

  • microsoft/windowsservercore
  • microsoft/nanoserver

I think it's coming from the Hyper-V layer in --isolation=hyperv mode, where a container is some sort of lightweight VM.

You can check isolation mode used for your existing container by docker inspect command.

If using a Linux container

For me, on Windows 10 using Docker Desktop, I could not get the --memory= and --cpus= options to work. Here's what does work:

  1. Right click on the Docker whale in the system tray and choose "Settings"
  2. Go to "Advanced" on the left
  3. Set how many CPUs and memory is available to containers here.

I think it might be that you have too much dead containers. Maybe try docker rm $(docker ps -a -q) to remove all the exited container then retry running the container you want.

No default limits. Documented here

We recently had a very similar problem and question and therefore made some experiments with docker memory on windows:

It seems that it heavily depends on you configuration. If you run docker containers in, lets call it hyper-v mode, the memory limit seems to be about 512mb. You can extend the given memory with the "-m" option for docker run. Assigning 2 gb have not been a problem.

Unfortunately, its totally different for windows server containers. There the starting memory limit is 1gb and you can decrease it with the "-m" option. We did not find a way to increase the memory for those containers.

How you see your mode/isolation level:

docker info -f "{{ .Isolation }}"

hyperv - hyper-v mode; process is windows server

Some additional notes: Its very hard to find a command that outputs the available memory in a container. We had created our own performance test for reliable results.

Run Docker QuickStart Terminal

Remove the default vm:

docker-machine rm default

Re-create the default vm: Depending on your requirements you can change the values for different parameters below.

docker-machine create -d virtualbox --virtualbox-cpu-count=2 --virtualbox-memory=4096 --virtualbox-disk-size=50000 default

Then do

docker-machine stop
exit

Now open the Docker quickstart terminal again

Now when you run and create a new container you will have more ram memory be default. But be careful it will delete already all pulled docker images.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!