Docker Desktop taking too much space on Windows? Here's the fix
You've run docker system prune, deleted old images, and your C: drive still hasn't gotten any smaller. This isn't a bug — it's how Docker Desktop's virtual disk works on Windows, and it needs one extra step to actually give the space back.
Why prune isn't enough
Docker Desktop on Windows runs on a WSL2 backend, storing all your images, containers, and volumes inside a single virtual disk file (a .vhdx) — typically at:
%LOCALAPPDATA%\Docker\wsl\disk\docker_data.vhdx
or, on older installs:
%USERPROFILE%\AppData\Local\Docker\wsl\data\ext4.vhdx
This file grows automatically as you pull images and build containers — but it doesn't shrink back down on its own when you delete things. Windows sees the file's maximum size, not how much of it is actually in use. Pruning frees space inside the virtual disk; it doesn't return that space to your C: drive until you compact the file itself.
Step 1: Clean up inside Docker first
docker system prune -a --volumes
This removes unused containers, networks, dangling images, and volumes. Do this before compacting — there's no point shrinking a disk full of things you don't need.
Step 2: Shut everything down
The virtual disk can't be compacted while it's in use.
- Right-click the Docker Desktop tray icon → Quit Docker Desktop
- Open Command Prompt or PowerShell and run:
wsl --shutdown
Step 3: Compact the virtual disk
If you're on Windows 10/11 Pro or Enterprise with the Hyper-V module available, open PowerShell as Administrator and run:
cd "$env:LOCALAPPDATA\Docker\wsl\disk" Optimize-VHD -Path .\docker_data.vhdx -Mode Full
On Windows 10/11 Home, the Hyper-V module usually isn't available. Use diskpart instead:
diskpart select vdisk file="C:\Users\YOURNAME\AppData\Local\Docker\wsl\disk\docker_data.vhdx" attach vdisk readonly compact vdisk detach vdisk exit
Can't find the file, or it has a different name?
Docker has changed the exact folder layout across versions. Check both %LOCALAPPDATA%\Docker\wsl\disk\ and %LOCALAPPDATA%\Docker\wsl\data\ — the file will be named either docker_data.vhdx or ext4.vhdx.
Step 4: Restart Docker Desktop
Open Docker Desktop normally — it will reattach to the (now smaller) virtual disk automatically.
Prevent it from happening again
In Docker Desktop, go to Settings → Resources → Advanced and set a disk size limit. It won't shrink the disk automatically for you, but it stops it from silently eating your entire drive between cleanups.
SweepDev catches this automatically
It flags Docker's virtual disk, WSL bloat, and node_modules clutter in one scan — no manual diskpart needed.
Join the beta waitlist