The problem
Docker Desktop on Windows stores everything in one virtual disk file on C:, and that file grows but never shrinks by itself. So I delete images, Docker says the space is free, and Windows still shows a red C: drive.
My fix is a two-part routine I run about once a week: clean up inside Docker, then shrink the disk file. Every time, it gives me back a lot of space.
Part 1: Clean inside Docker
Docker Desktop must be running for this part. Open a normal PowerShell window.
1. Check usage before
docker system df 2. Delete the build cache (always safe)
docker builder prune -a -f 3. Delete unused images (safe, they download again when needed)
docker image prune -a -f 4. Check unused volumes before deleting anything
Volumes hold real data, like your database, so look first.
docker volume ls -f dangling=true - Only random long names in the list? Delete them all with
docker volume prune -a -f. - A real name you still need, like
myapp_db_data? Skip this step.
The -a flag removes named volumes too. Without it, docker volume prune -f only removes anonymous ones (Docker docs).
5. Check usage after
docker system df Docker now reports much less usage. But open File Explorer and C: looks the same.
Part 2: Shrink the disk file
This is the part that gives C: its space back. Docker must be fully quit for it.
6. Find your disk file and its size
This command lists every Docker disk file on your PC with its size in GB. Copy and paste it as it is.
Get-ChildItem "$env:LOCALAPPDATA\Docker\wsl" -Recurse -Filter *.vhdx | Select FullName, @{n='GB';e={[math]::Round($_.Length/1GB,1)}} The output looks like this:
FullName GB -------- -- C:\Users\<your-username>\AppData\Local\Docker\wsl\disk\docker_data.vhdx 38.6 C:\Users\<your-username>\AppData\Local\Docker\wsl\main\ext4.vhdx 0.1 The big file, docker_data.vhdx, is the one to shrink. Copy its full path, you need it in step 9. On older Docker Desktop versions the big file is ext4.vhdx inside Docker\wsl\data.
7. Quit Docker Desktop
Right-click the whale in the system tray and choose Quit Docker Desktop.
8. Shut down WSL
Open PowerShell as Administrator and run:
wsl --shutdown 9. Compact the file with diskpart
diskpart Inside DISKPART, run these one line at a time. Use your own path from step 6.
select vdisk file="C:\Users\<YourName>\AppData\Local\Docker\wsl\disk\docker_data.vhdx" attach vdisk readonly compact vdisk detach vdisk exit 10. Start Docker Desktop again
Run the step 6 command once more to see the new size.
Gotchas
- Never delete the
Docker\wslfolder by hand. That folder is all your images, containers and volumes. - Don't skip
detach vdisk, or Docker may not start. If that happens, restart the PC. - If
attachsays the file is in use, quit Docker Desktop and runwsl --shutdownagain.
That's it
Prune inside Docker, then compact the file. I run both parts about once a week and C: stays usable.
Do you clean Docker a different way? Tell me in the comments.



![[BOSNIAN LANGUAGE] useState je jednako moćno kao i useReducer](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnwwbmmkrbuxqkz1k9oos.png)