Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AhmedSakrr/ec35890b725f7569c81a698dd7343c57 to your computer and use it in GitHub Desktop.

Select an option

Save AhmedSakrr/ec35890b725f7569c81a698dd7343c57 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

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