Docker windows container memory limit
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.
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.
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: