5-Minute Guide: How to Efficiently Limit RAM Usage on Windows while using Docker 🐬

Rohan Dawkhar
2 min readJun 18, 2023

--

Limiting RAM usage for Docker Desktop (Vmmem)

Table of Contents -

  1. Introduction
  2. How to limit RAM usage ?
  3. References
  4. 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! 😊

--

--

Rohan Dawkhar
Rohan Dawkhar

Written by Rohan Dawkhar

Currently pursuing MS in Data Science at the University of Maryland College Park, Open Source Contributor, Problem solver, and ex Data Science Intern at Kampd

No responses yet