5-Minute Guide: How to Efficiently Limit RAM Usage on Windows while using Docker đŹ
Table of Contents -
- Introduction
- How to limit RAM usage ?
- References
- Connect with me!
1. Introduction
Hello everyone !
If you are using Docker on Windows with the help of WSL2 backend, do check out the Task Manager and monitor how much RAM does Vmmem consume. Virtual machine can consume a lot of RAM while using WSL backend software or Virtual environments. This can make our machine slow, unable to run new programs, etc. We need to limit on how much Docker can consume RAM, even after running multiple containers.
2. How to limit RAM usage ?
Go to search bar of Windows, present in bottom left corner (beside Windows button) and type âpowershellâ. Click on âWindows PowerShellâ.
We will create a .wslconfig file in our user home directory by typing the below code. Put your user profile name instead of USERPROFILE.
notepad "$env:USERPROFILE/.wslconfig"
Add the following into your newly created .wslconfig file. I wanted to limit the memory up to 2 GB, so added memory=2GB. You can add customized memory according to your need.
[wsl2]
memory=2GB # Limits VM memory in WSL 2 up to 2GB
Note- If you want to know, whether youâre using WSL2 backend or not, go to Docker Desktop -> Settings -> Resources. There, youâll be able to see the WSL version.
Note- You might have to restart your PC to make these changes work. I had to restart Docker and the changes were effective.
After making these changes, youâll see in Task Manager that the RAM consumption has reduced to 2 GB (approximately) while using Docker on Windows machine.
3. References
4. Connect with me!
đ Thatâs a wrap on my technical blog! If you have any questions or need further clarification on the topics covered, feel free to reach out to me. Iâm here to help!
If youâre looking for a talented technical writer, Iâm available for hire. Letâs collaborate and bring your ideas to life! đ