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
- Docker Desktop → Settings → General → check Use the WSL 2 based engine.
- Settings → Resources → WSL Integration → enable the distros where you want
dockeravailable (such as Ubuntu) → Apply & Restart.
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:
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 thedocker-desktop-data WSL distro, by default at:
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:
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.
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
- Where data lives: volume vs bind mount performance on WSL 2.
- Docker CLI commands: cleanup commands to reclaim VHDX space.