Skip to content

Instantly share code, notes, and snippets.

@jctosta
Created June 14, 2021 21:23
Show Gist options
  • Save jctosta/a8942ff4f8fbf01e339a0579172cb9fe to your computer and use it in GitHub Desktop.
Save jctosta/a8942ff4f8fbf01e339a0579172cb9fe to your computer and use it in GitHub Desktop.
You can limit docker-windows memory usage by adjusting some parameters in wsl2 configuration.

Limit WSL2 Memory Usage when using Docker for Windows

You can limit docker-windows memory usage by adjusting some parameters in wsl2 configuration.

First, close any instances of Docker Windows currently running and create a new file named .wslconfig in your user home directory, like C:\Users<username>:

[wsl2]
memory=4GB
processors=5

Save the file, open a Power Shell window with administrator privileges and execute the following command to restart any WSL2 instances and apply the new confiuguration:

Restart-Service LxssManager

After this, just restart Docker-Windows to get an instance of WSL2 with the new configuration applied.

Source: https://medium.com/@lewwybogus/how-to-stop-wsl2-from-hogging-all-your-ram-with-docker-d7846b9c5b37

@gabrielsmenezes
Copy link

gabrielsmenezes commented Mar 27, 2023

Extremely helpful. I have 12GB of RAM and docker was consuming almost 10GB.

I limited docker to 2GB and it's working better than after.

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment