Skip to main content
Docker WSL 2 Configuration This is the easiest thing to get wrong on Windows: under the WSL 2 backend, Docker’s CPU and memory are not set in the Docker Desktop GUI; they are controlled by the WSL 2 utility VM’s config file.

Connecting to the WSL 2 backend

  1. Docker Desktop → Settings → General → check Use the WSL 2 based engine.
  2. Settings → Resources → WSL Integration → enable the distros where you want docker available (such as Ubuntu) → Apply & Restart.
With integration on, you can use docker directly from that distro’s Linux terminal.
Only the Hyper-V backend (or macOS / Linux) sets CPU / memory / swap directly under Docker Desktop’s Settings → Resources → Advanced. The WSL 2 backend uses .wslconfig below.

Allocating resources (.wslconfig)

CPU / memory / swap are set in the [wsl2] section of %UserProfile%\.wslconfig (create the file if missing). The [wsl2] section header is mandatory, or the settings are ignored:
Restart WSL to apply:

Common WSL integration commands

Where Docker data lives and how to check its size

Under the WSL 2 backend, Docker’s image layers, containers, and volume data all live in the virtual disk (VHDX) of the docker-desktop-data WSL distro, by default at:
The docker-desktop-data VHDX is the source of disk usage. It grows dynamically but does not shrink back automatically, and File Explorer does not show its real usage; check with a command:
Reclaim space via the cleanup commands (docker system prune). To move the VHDX: Docker Desktop → Settings → Resources → Advanced → Disk image location.

daemon.json (Docker engine settings)

To tune registry mirrors, log rotation, default runtime, and other engine-level settings, edit the daemon config. On Docker Desktop you do not edit the file directly; use the JSON editor under Settings → Docker Engine. Only native Linux installs use /etc/docker/daemon.json.
Common keys: log-opts caps per-container log size and file count (worth adding by default so logs do not fill the disk), registry-mirrors speeds up pulls, data-root changes the data root, live-restore keeps containers running across a daemon restart.

Next

Reference: docs.docker.com/desktop/features/wsl, learn.microsoft.com/windows/wsl/wsl-config