Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Docker Desktop takes most of the machine's RAM and then freezes or crashes

Your error

vmmem.exe uses most of the RAM in Task Manager while Docker Desktop runs2 more lines it can show

Fix it fast

Most common cause, 1 of 3

WSL is older than Docker Desktop's minimum (Windows, WSL 2 backend)

Update WSL, shut the WSL 2 VM down so the new version loads, then start Docker Desktop again.

Fix
wsl --update
wsl --shutdown
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

When vmmem.exe or the Docker Desktop VM eats most of the RAM until the machine freezes, the Linux VM has no cap that suits the machine: by default it may use half of host memory. Update WSL to 2.1.5 or later, cap the VM in .wslconfig or Settings > Resources, and limit heavy containers (Docker Desktop 4.x).

  • Applies to Docker Desktop 4.100, WSL 2.1.5 or later, Windows 11 23H2 or later, Windows 10 22H2, macOS
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Check the three layers from the outside in: the WSL version on Windows, the memory the Docker VM was given, and how much of it each container holds. Total Memory in docker info is the VM's size, not the host's.

Run this first
wsl --version
docker info | grep "Total Memory"
docker stats --no-stream

Then find the line you see in this list and open its fix:

  1. 1WSL is older than Docker Desktop's minimum (Windows, WSL 2 backend)wsl --version prints a WSL version below 2.1.5, or the command is not recognized, which means the old inbox WSL
  2. 2The Docker VM has no memory cap that fits the machinedocker info reports a Total Memory close to half of the host's RAM or more, and no .wslconfig file exists (WSL 2) or the Memory limit was never changed (macOS, Linux, Hyper-V)
  3. 3Containers run without memory limits and fill the VMdocker stats shows one container's MEM USAGE close to its LIMIT, and that LIMIT equals the VM's Total Memory, so no limit was set

What does the error look like?

  • vmmem.exe uses most of the RAM in Task Manager while Docker Desktop runs
  • Windows or macOS slows to a crawl once a few containers are up, then Docker Desktop stops responding
  • docker stats shows one container using almost all of the memory the VM has

Cause 1 of 3

WSL is older than Docker Desktop's minimum (Windows, WSL 2 backend)

You seewsl --version prints a WSL version below 2.1.5, or the command is not recognized, which means the old inbox WSL

Check

On Windows, vmmem.exe consuming all memory is one of the problems Docker lists for outdated WSL releases, next to hangs and GPU failures. Docker Desktop needs WSL 2.1.5 at a minimum and expects the latest release, so an old WSL alone can explain the memory use.

Check
wsl --version
wsl --status

Fix

Update WSL, shut the WSL 2 VM down so the new version loads, then start Docker Desktop again.

Fix
wsl --update
wsl --shutdown

Verify

wsl --version now reports 2.1.5 or newer, and memory settles once Docker Desktop is back up.

Verify
wsl --version

Confirmed by docs.docker.com

Did this fix it?

Cause 2 of 3

The Docker VM has no memory cap that fits the machine

You seedocker info reports a Total Memory close to half of the host's RAM or more, and no .wslconfig file exists (WSL 2) or the Memory limit was never changed (macOS, Linux, Hyper-V)

Check

Docker Desktop runs containers inside one Linux VM, and that VM is sized generously by default. With the WSL 2 backend Docker Desktop leaves the limits to the WSL 2 utility VM, which takes up to 50% of Windows memory plus swap of 25% of Windows memory unless .wslconfig says otherwise. On macOS, Linux and the Hyper-V backend, the Memory limit under Resources also starts at 50% of host memory.

Check
docker info | grep "Total Memory"
Get-Content "$env:USERPROFILE\.wslconfig"

Fix

Cap the VM. For WSL 2, write the limits into %UserProfile%\.wslconfig and restart WSL; for the other backends, lower Settings > Resources > Advanced > Memory limit and apply.

Fix
# %UserProfile%\.wslconfig
[wsl2]
memory=6GB
swap=2GB

wsl --shutdown

Verify

After Docker Desktop restarts, docker info shows the new, smaller Total Memory.

Verify
docker info | grep "Total Memory"

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

Containers run without memory limits and fill the VM

You seedocker stats shows one container's MEM USAGE close to its LIMIT, and that LIMIT equals the VM's Total Memory, so no limit was set

Check

A container has no resource constraints unless you add them, so one leaking app or a database with a large cache can take the whole VM. When the VM runs out, the kernel starts killing processes to free memory; Docker lowers the daemon's own OOM priority, so a container is the more likely victim.

Check
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}"

Fix

Give the heavy services a memory limit sized for their real working set, on the command line or in compose.yaml.

Fix
docker run -d --name api -m 1g my-api

# compose.yaml
services:
  api:
    image: my-api
    deploy:
      resources:
        limits:
          memory: 1G

Verify

The LIMIT column for that container now shows the cap instead of the VM's total.

Verify
docker stats --no-stream api

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Write a .wslconfig with a memory cap when a Windows machine is first set up for Docker, and run wsl --update at the same time.
  • Keep memory limits for every long-running service in compose.yaml, so a leak stops at its own limit.
  • Leave Resource Saver on (macOS, Linux, Hyper-V backend): it turns the VM off while no containers run and hands the memory back.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Dispatch Pro.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.