Docker's disk on Windows is a WSL virtual disk that only grows
Images, volumes and build cache inside a vhdx that never shrinks by itself. The prune order and the compaction step.
Docker Desktop on Windows stores everything inside a virtual disk managed by WSL. That file grows as you build and never shrinks on its own, so pruning inside Docker frees space inside the file rather than on your drive.
Finding the disk
Get-ChildItem "$env:LOCALAPPDATA\Docker\wsl" -Recurse -Filter *.vhdx -EA SilentlyContinue |
Select-Object @{n='GB';e={[math]::Round($_.Length/1GB,2)}}, FullName
docker system dfdocker system df reports images, containers, volumes and build cache with a reclaimable figure for each. Read that before pruning anything, because it separates what is genuinely unused from what a running container needs.
What each prune removes
| Command | Removes | Risk |
|---|---|---|
docker builder prune | Build cache | None. Rebuilds are slower |
docker image prune -a | Images no container uses | Redownload or rebuild |
docker container prune | Stopped containers | Anything written inside them |
docker volume prune | Volumes nothing references | Data. This is the dangerous one |
docker system prune -a --volumes | All of the above | Everything above at once |
Then reclaim the disk
After pruning, the vhdx is still the size it was. Docker Desktop has a Disk usage view with a Reclaim space action, and recent versions can do it automatically. The manual route is to shut WSL down and compact the disk, which is the same procedure as any WSL distribution:
wsl --shutdown
# then compact, either through Docker Desktop's own setting
# or with diskpart's compact vdisk on the vhdxThe habit that keeps it small
- Run
docker builder pruneweekly, filtered by age. Build cache grows fastest and is safest to remove. - Use
docker image prune -aafter finishing a project, not during one. - Name your volumes, so
docker volume lsis readable when it comes to pruning. - Check
docker system dfbefore assuming Docker is the problem.
Common questions
Why does pruning Docker not free space on Windows?
Because everything lives inside a WSL virtual disk that only grows. Pruning frees space inside that file, and the file has to be compacted separately before Windows sees it.
Where is Docker's disk on Windows?
Under %LOCALAPPDATA%\Docker\wsl as a .vhdx file. Docker Desktop's Disk usage view shows its size and offers a reclaim action.
What is the difference between docker system prune and prune with volumes?
Without the volumes flag it removes stopped containers, unused networks, dangling images and build cache, all rebuildable. Adding --volumes also removes volumes nothing references, and those hold real data.
How do I shrink the Docker vhdx?
Prune inside Docker first, then use Docker Desktop's reclaim space action, or shut WSL down and compact the disk with diskpart.