Docker on windows 11 with WSL2 does not use the memory I set in .wslconfig

I’m new to Docker, so I probably make simple mistake. Hope you can help.

I have a PC with 32 GB ram and I need 20 GB available in Docker.

I use WSL2 and I have tried to overwrite the default memory limit with the .wslconfig file.

This is the content of my file:

When I try to run a container I can see in Docker Desktop that only 15.17GB is available.

Kind regards
Thomas Madsen Nielsen

Did you also restart WSL?

Note

Configuring global settings with .wslconfig are only available for distributions running as WSL 2 in Windows Build 19041 and later. Keep in mind you may need to run wsl --shutdown to shut down the WSL 2 VM and then restart your WSL instance for these changes to take effect.

Setting the limit for WSL utility vm does not equal to the limit Docker Desktop can use: the backend requires resources as well.

If I use this configuration, Docker Desktop shows 20.01GB as usable:

[wsl2]
memory=22523412480

I configured 21480MB with the WSL Settings program (only available on fairly new WSL2 version)

This is actually a must!

Thanks for your help rimelek and mayay.

In the end the problem showed to be me creating .wslconfig with notepad and it automatic added .txt to the file name. At the same time I’m used to file explorer showing file extensions, but this is a new PC, so that was switched off, and I didn’t notice the problem.

I have now set the memory=22523412480 as suggested by mayay and it works - and it can even utilize CPU more than 100% :slight_smile:

Thanks.

1 Like