TechBuzzPro

Docker Engine in WSL vs Docker Desktop Memory Use

· 6 min read · Windows & PC

In this article
  1. Background: Docker on Windows Before WSL 2
  2. How Docker Desktop Uses Memory in WSL 2
  3. How Docker Engine Directly in WSL Uses Memory
  4. Memory Comparison: Realistic Scenarios
  5. How to Measure and Optimize Memory Usage
  6. Choosing Between Docker Desktop and Docker Engine in WSL
  7. Common Problems and Misconceptions
  8. Frequently Asked Questions

Yes, running the Docker Engine directly inside WSL 2 generally uses less memory than Docker Desktop, because Docker Desktop adds a separate virtual machine layer and its own management processes on top of the same WSL 2 backend. However, the exact difference depends on your workload, your WSL configuration, and how you measure memory. This article explains why that gap exists, how each setup works, and how to choose the right approach for your needs.

Background: Docker on Windows Before WSL 2

Before WSL 2, Docker on Windows required either Hyper-V with a full Linux VM (Docker Toolbox used VirtualBox) or Docker Desktop with its own Hyper-V VM. That VM had a fixed memory allocation, often 2–4 GB, regardless of whether your containers used it. The VM also added boot time and CPU overhead. WSL 2 changed the game by introducing a lightweight utility VM that shares the Windows kernel’s memory management. Docker Desktop now uses this same WSL 2 backend, but it wraps it with additional components.

How Docker Desktop Uses Memory in WSL 2

Docker Desktop on WSL 2 creates two WSL distros: docker-desktop and docker-desktop-data. The first runs the Docker daemon and the second stores container images and data. On top of that, Docker Desktop runs a Windows-side GUI, a background service (com.docker.backend), and a VPNKit process for networking. Each of these consumes memory that a bare Docker Engine inside WSL does not need.

Docker Desktop also sets a default memory limit for its WSL VM, typically 50% of your total RAM or 8 GB, whichever is lower. This limit is a cap, not a reservation, but it can cause the VM to grow and retain memory that the host could otherwise reclaim. In practice, Docker Desktop often shows 1–2 GB of baseline memory usage even with no containers running, due to the GUI and backend processes.

How Docker Engine Directly in WSL Uses Memory

When you install Docker Engine inside a WSL 2 distro (for example, Ubuntu), you run the daemon as a regular Linux process. There is no Windows-side GUI, no separate backend service, and no VPNKit. The WSL 2 VM itself is shared with your other Linux tools, and its memory is dynamically allocated by Windows. The Docker daemon itself typically uses 50–150 MB, and each container adds the memory of its processes. With no containers running, the daemon sits idle at a low baseline.

WSL 2 has a global memory limit (default 50% of total RAM or 8 GB, whichever is smaller) and a cache that can grow. However, Windows reclaims memory from the WSL VM when other applications need it, and you can also set .wslconfig to cap WSL memory to a smaller value. This gives you finer control than Docker Desktop’s separate VM.

Memory Comparison: Realistic Scenarios

The difference is not huge for a single container, but it compounds with many containers or long-running daemons. Consider a typical development setup:

  • Docker Desktop idle: ~1.5–2.5 GB (GUI, backend, VPNKit, and the VM’s base).
  • Docker Engine in WSL idle: ~200–400 MB (daemon plus WSL base).
  • Running 5 small containers: Docker Desktop adds ~500 MB overhead, while Docker Engine adds only the container processes themselves.

If you have 16 GB of RAM, the difference is noticeable but not critical. On an 8 GB machine, it can be the difference between running your stack and hitting swap. The exact numbers depend on your Windows version, WSL version, and Docker version, so treat these as ballpark figures, not guarantees.

How to Measure and Optimize Memory Usage

To see actual memory usage, use the Windows Task Manager (Processes tab) and look for com.docker.backend, vpnkit.exe, and the WSL VM process (vmmem). In WSL, run free -h or docker stats to see container-level usage. If you want to minimize memory:

  1. Switch Docker Desktop to WSL 2 backend (if you must use Desktop).
  2. In .wslconfig, set memory=4GB or a value that fits your workload, and swap=0 if you want to force reclaim.
  3. Stop Docker Desktop when not in use; it does not auto-shutdown by default.
  4. For Docker Engine in WSL, set DOCKER_RAM limits per container with --memory flags.

Note that WSL 2’s memory cache (page cache) can grow to the limit, but Windows will reclaim it under pressure. If you see high vmmem usage, it is often cache, not actual container memory.

Choosing Between Docker Desktop and Docker Engine in WSL

Your choice depends on your priorities:

  • Ease of use: Docker Desktop provides a GUI, automatic updates, and seamless integration with Windows file sharing and localhost. Choose it if you want minimal setup.
  • Memory efficiency: Docker Engine in WSL is leaner and gives you more control. Choose it if you are memory-constrained or want a Linux-native experience.
  • Compatibility: Docker Desktop supports Kubernetes, Docker Compose V2, and extensions out of the box. Docker Engine in WSL requires manual setup for these.
  • Licensing: Docker Desktop is free for small businesses and personal use, but larger enterprises may need a paid subscription. Docker Engine is open-source and free for all.

If you already use WSL for development, installing Docker Engine inside your distro is straightforward and avoids running two WSL VMs (one for your distro and one for Docker Desktop).

Common Problems and Misconceptions

A frequent misconception is that Docker Desktop “uses less memory” because it has a GUI to show usage. In reality, the GUI is part of the overhead. Another issue is that Docker Desktop’s WSL VM is separate from your main WSL distro, so you might end up with two VMs consuming memory. If you run Docker Engine inside your existing WSL distro, you avoid that duplication.

Another common problem is that Docker Desktop sometimes fails to release memory after containers stop, due to its caching. Docker Engine in WSL also caches, but you can run docker system prune to reclaim disk and memory. Also, if you set .wslconfig memory too low, both setups will fail to start containers with out-of-memory errors; always leave headroom for the Windows host.

Frequently Asked Questions

Does Docker Desktop use the same WSL 2 VM as my Ubuntu distro?

No. Docker Desktop creates its own dedicated WSL distros (docker-desktop and docker-desktop-data) that are separate from your user distro. This means you have two WSL VMs running if you also use Ubuntu, which increases memory usage. Docker Engine installed inside your Ubuntu distro uses that same VM, so only one VM exists.

Can I run Docker Engine in WSL without Docker Desktop?

Yes. Install the Docker Engine package inside your WSL 2 distro (e.g., Ubuntu) and start the daemon with sudo service docker start. You do not need Docker Desktop at all. You will lose the GUI and some convenience, but you gain lower memory usage and a more Linux-native environment.

Why does my WSL memory usage stay high even after containers stop?

WSL 2 caches file pages from Linux to speed up disk access. This cache is released when Windows needs memory, so high usage is not necessarily a problem. You can force a release by running echo 3 > /proc/sys/vm/drop_caches (requires root) or by restarting WSL with wsl --shutdown.

Is Docker Desktop faster than Docker Engine in WSL?

Performance is generally similar because both use the same WSL 2 kernel. Docker Desktop may have slightly higher I/O overhead due to its networking layer (VPNKit), but for most workloads the difference is negligible. Memory usage is the more significant factor.

Can I set a memory limit for Docker Engine in WSL?

Yes. Use Docker’s --memory flag per container, or set a global WSL memory limit in .wslconfig. For example, memory=4GB caps the entire WSL VM, which includes your containers and any other Linux processes.

Does Docker Desktop work with WSL 1?

No. Docker Desktop requires WSL 2. WSL 1 does not support the full Linux kernel needed for Docker. If you are on WSL 1, you must convert to WSL 2 with wsl --set-version <distro> 2 before using Docker Desktop.