Docker desktop eats all memory and crashes

Viewed 17354

Using Docker Desktop (19.03.13) with 6 containers in Windows 10. Having 16GB RAM.

In docker stats each container consumes 20-500 mb, all together cunsume ~1gb.

But in the Task Manager docker eats ~10gb and crashes from the lack of system memory.

How to check, what consumes so much memory in docker? And how to prevent this?

6 Answers

Try to create a .wslconfig file at the root of your User folder C:\Users\<my-user> to adjust how much memory & processors Docker will use.

This is the content of the .wslconfig file.

[wsl2]
memory=2GB   # Limits VM memory in WSL 2 up to 2GB
processors=2# Makes the WSL 2 VM use two virtual processors

Then, restart the computer. You will find the Vemm process will only take the amount of RAM you defined previously.

You can learn more here here

I guess you are using the new WSL 2 based engine, try switching docker engine back to Hyper-V by going opening docker settings -> general -> uncheck Use WSL 2 based Engine .

To explain:

I noticed it started happening to me since WSL 2 engine was introduced, i automatically switched to it since it's a new engine; Memory issues started arising since then.

Restarting/closing docker did not free the memory and i noticed in task Manager Vemm was the one eating all memory, so had to force close it (caused docker not to work).

Last thing i did was switching docker engine back to Hyper-V solved my high memory usage.

If you are using WSL2 put into the .wslconfig the middle of your ram. I don't know why but I had the same problem with 8GB RAM.

This is my .wslconfig

[wsl2]
memory=4GB # I have 8GB RAM
processors=2 

And the result was good because the consumption is good! In this moment I have running a Docker with 8 images:

The result was the following

Although this problem is already marked as SOLVED

There is still another reason for this, in recently updated versions.

You might enable too many resources for docker hyperkit.

Go to settings - resources - advanced check if you spared too much resource there. enter image description here

I am guessing on Windows there is something similar to what exists on MacOS.

  1. Open your docker app and go to the dashboard
  2. Click any container
  3. Click Stats

You will get information regarding your CPU, RAM Usage, Disk Read & Write Memory & Network usage.

enter image description here

When I had memory issues, which I used to frequently, I would setup alias scripts that I could chain together to stop/kill/restart and do what ever setup I needed on the containers.

There is no preventing docker behaving the way it behaves unless you want to start contributing to and making pull requests. This isn't an uncommon issue. Docker is a free service, I recommend working around it's short comings.

Related