Ideas or code sources:
Hello, Docker on Windows lovers.
Just found a good article about how to control resources of WSL2 instances while using Docker for Windows. That’s could be useful if you’re using laptop.
This configuration is global for all WSL2 distros. To configure per distro, please refer to official documentation: WSL Config
TLDR;
Open your favourite file explorer, navigate to c:\users\*your profile name*
and create a .wslconfig
file with following structure:
[wsl2]
memory=4GB # Limits VM memory in WSL2 to 4 GB
processors=2 # Makes the WSL2 VM use two virtual processors
After that, open PowerShell
console with Admin Rights and restart WSL2 process:
Restart-Service LxssManager
Name of the process in Task Manager is vmmem
, so you can check before change and after change memory usage.
That’s it.
Happy Docker4Windows
ing.