Does docker windows containers, with Docker Desktop for Windows, have default memory limit?
I have an application that was crashing when I run it in the container, but when I tried to specify --memory 2048mb
parameter to the docker run
command it seems to run fine. At least in the scenario where it was crashing before. This gives me impression that there is default memory limit, but I could not find it in the documentation. So my question is there memory limit and if it is where it is documented?
-
2Fyi, in HyperV isolation mode (which is the default for Windows containers on Desktop OSes) there’s also a disk space limit of 20GB, which can also be overidden. – Nick Muller Jun 13 '19 at 18:17
11 Answers
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.

- 2,835
- 1
- 22
- 28

- 749
- 4
- 16
-
-
25
-
4I have a similar issue, however docker caps out at 1.943GiB (according to `docker stats`), even if I specify more memory (with `-m`) – Murray Patterson Apr 09 '20 at 22:07
-
-
3
-
jfyi - https://stackoverflow.com/questions/28837544/can-i-use-mem-limit-in-docker-compose-and-how – Victor Apr 29 '20 at 13:41
If using a WSL 2 container
This seems to be the norm now (in 2023). You need to create/edit a file in your user profile directory.
cd %UserProfile%
notepad .wslconfig
Then, make sure it has at least something like this:
[wsl2]
memory=6GB # Limits VM memory in WSL 2
Reboot your machine and you should have more memory for your containers.
(props to @nessa.gp for this answer)
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:
- Right click on the Docker whale in the system tray and choose "Settings"
- Go to "Resources -> Advanced" on the left
- Set how many CPUs and memory is available to containers here.

- 23,006
- 14
- 93
- 108
-
10These settings are for when Docker runs in Linux mode, which uses a full hyper-v vm. If you switch to Windows mode, these settings disappear. – Nick Muller Jun 13 '19 at 18:13
-
@NickMuller In Windows mode, I'm guessing I can't run Linux VMs? Alpine & Ubuntu is what I want since that's how we deploy in prod. – Ryan Shillington Jun 13 '19 at 20:57
-
True, but the question was about Windows containers, not Linux containers. By the way, there's a new feature where you can run Linux containers in Windows mode. Still experimental though. See: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers#linux-containers-with-hyper-v-isolation – Nick Muller Jun 14 '19 at 07:06
-
@NickMuller : Adjusting Mem size for linux container is quite straight forward because it's part of Docker's settings. For Windows container, you need to go to Hyper-V Manager, and in the right pane, there's a Setting option under DockerDesktopVM. In Setting dialogbox, you can adjust mem size for container dynamic or static, – KMC Sep 20 '19 at 15:54
-
In case memory limits kick in when switching from Windows to Linux containers, please see https://stackoverflow.com/questions/52904104/how-to-reduce-default-vm-memory-for-docker-linux-containers-on-windows – Oliver Hader Jan 03 '20 at 11:45
-
On windows 10, I found that once I adjusted the memory slider I was able to create containers that used more than 2 GB of memory (which was the default limit on my system). – Max Jun 15 '20 at 18:50
-
2Side note: The settings also disappear in WSL2 Mode. It does tell you how to configure them instead though. – Egor Hans Nov 22 '21 at 10:19
With WSL2, as documented here, you can create a .wlsconfig file in your user home directory, type from the PowerShell:
notepad "$env:USERPROFILE/.wslconfig"
And the contents of the file to limit memory are the following:
[wsl2]
memory=3GB # Limits VM memory in WSL 2 up to 3GB
In order to see if you are using WSL2 you can do so from the docker interface:

- 1,804
- 21
- 20
-
4Thanks. This worked for me. I had to restart my computer for it to take effect. – Kmeixner Mar 18 '22 at 14:44
-
1
-
Depends on your machine of course and how you work. In my case, I have 16gb ram, Windows already takes close to 2gb, Microsoft teams another 2gb when in video call, etc, so 3gb works for me. So, check the task manager when things are busy to have a rough estimate, remember to leave some room to open some extra apps if needed and play with different values to see what works for you. – nessa.gp Jul 20 '23 at 07:57
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.

- 9,089
- 4
- 61
- 74
-
Thanks! Do you know where the limit come from? Is is docker setting or image setting? – Andrey M. May 07 '17 at 18:41
-
TBH no idea... could be from Hyper-V layer too, as Windows containers are based on it. Anyway you can set it with "-m" option, which solves it, does it not? – Ivan May 07 '17 at 18:44
NOTE: Switching to Linux containers and playing with the "Settings Resources > Advanced" options only modifies the VM resources for running Linux containers, and not Windows containers.
Solution
To adjust the amount of memory and CPU cores used for Windows containers you will need to use the --memory
and --cpus
argument flags when you run the image. For example:
docker run --name myWinImage --memory 4096m --cpus 2 -it -p ‘4096:7880’ --entrypoint powershell
Do NOT forget to append an "m" with number you set for the --memory
flag as in "4096m" or it will have no effect. Also the memory flag has a short version -m 4096m
.
Testing
You can verify that setting the flags worked by opening a Powershell terminal to the running container:
To check memory, run:
systeminfo | select-string 'Total Physical Memory'
To check CPUs, run:
Get-WmiObject -class Win32_processor | Format-Table Name,NumberOfCores,NumberOfLogicalProcessors
This article really helped me figure it out: https://www.sqlservercentral.com/blogs/default-resource-limits-for-windows-vs-linux-containers-in-docker-desktop

- 3,738
- 1
- 22
- 38

- 4,076
- 2
- 30
- 30
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 by default. But be careful it will delete already all pulled docker images.

- 131
- 1
- 1
- 11
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.

- 86
- 4
-
2I've found that -m has no effect in Windows Server 1709 (core) running docker EE preview. Did you ever find a way to "increase the memory for [windows server] containers? – FizxMike Apr 25 '18 at 02:12
-
1@FizxMike Me too, I am running a Kafka container and although I have assigned 4GB memory using -m, the container stops when hitting 1GB... – Adhip Rebello Jul 12 '20 at 11:32
To create a .wslconfig file, simply open your File Explorer, and type and enter %UserProfile% to go to your profile directory in Windows.
Docker or WSL2 by default does not create these config files so we should do it ourselves. Create a new file called .wslconfig (make sure there are no .txt at the end)
Add the (either all or some of the) following commands in that file to configure docker
# Settings apply across all Linux distros running on WSL 2
[wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole
numbers using GB or MB
memory=4GB
# Sets the VM to use two virtual processors
processors=2
# Specify a custom Linux kernel to use with your installed distros.
kernel=C:\\temp\\myCustomKernel
# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
kernelCommandLine = vsyscall=emulate
# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=8GB
# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
swapfile=C:\\temp\\wsl-swap.vhdx
# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
pageReporting=false
# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true
# Disables nested virtualization
nestedVirtualization=false
# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=true
Now you can set your desired Memory and virtual processor config. After that close your Docker desktop and open it again.
that's all, Enjoy

- 1,449
- 2
- 12
- 26
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.

- 732
- 1
- 8
- 15
-
Thanks for your answer. No I don't have much containers. `docker ps -a` shows only 3 containers which I use. – Andrey M. Apr 18 '17 at 09:03
You can also set the memory used by docker by editing the json file C:\Users\Personal\AppData\Roaming\Docker\settings.json . Look for a property called MemoryMiB and update its value to be the number of megabytes you want your docker installation to use.

- 2,699
- 28
- 29