WSL and Docker ate your disk
WSL2 and Docker Desktop keep their Linux worlds inside virtual disk files - ext4.vhdx and docker_data.vhdx. These files grow on demand and never shrink on their own: delete 30 GB inside Linux, and Windows still sees the same huge file. On dev machines they are routinely the single largest objects on C:.
Find them first
They hide deep under AppData\Local\Packages (per-distro) and AppData\Local\Docker. On a disk map they are unmissable: one enormous file sector where system files should be small. In CleanMyWin the .vhdx icon marks them as disk images - if you see one at 80 GB, this article is for you.
Shrink them properly
First free space inside the VM (docker system prune -a inside Docker, delete junk inside the distro), then compact the file from Windows:
- wsl --shutdown - stop everything first, always.
- Docker Desktop: Settings > Resources > Advanced has a disk size control; the built-in "clean / purge data" resets the file entirely.
- Distro VHDX: wsl --manage <distro> --set-sparse true on current WSL makes the file give space back automatically.
- Older setups: diskpart > select vdisk file="...ext4.vhdx" > compact vdisk.
Keep it from happening again
- docker system prune on a schedule - unused images are the main filler.
- Keep big datasets on a Windows drive mounted into WSL (/mnt/d/...) instead of inside the VHDX.
- Sparse VHDX (above) makes the whole problem mostly disappear on recent WSL.
Frequently asked
Why is ext4.vhdx so big after I deleted files in WSL?
The virtual disk grows on demand but does not return space to Windows by itself. Enable sparse mode or compact it with diskpart after wsl --shutdown.
Is it safe to delete docker_data.vhdx?
Only via Docker Desktop's own purge/reset - deleting the file by hand while Docker runs corrupts its state. You lose all local images and containers either way.
Sources and official documentation: Microsoft: Free up drive space in Windows, Microsoft: Storage Sense, Microsoft: WSL disk space, DaisyDisk, WizTree, WinDirStat, TreeSize
See where your terabytes went
One scan takes a minute. The first 24 hours are free.
Download for Windows