Docker images and containers are deleted, but the Windows disk is still full
docker rm and docker rmi finish, but the C: drive stays fullShort answer
Two separate things hold space. Docker itself keeps volumes, tagged images and build cache that a plain prune leaves alone. And on Windows the data lives in a virtual disk file that grows as you use it but does not shrink by itself. Prune what Docker keeps, then compact the .vhdx with Windows tools.
Fix it fast
1Find out which cause you have
Ask Docker how much space it believes it uses, split by type. If the numbers are small, Docker is clean and the space is held by the virtual disk file.
docker system df2Match what you see, then jump to its fix
- 1
docker system df shows large reclaimable numbers for images, local volumes or build cache.Volumes, tagged images and build cache were not prunedFix - 2
docker system df is small, yet the .vhdx file on Windows is many gigabytes.The WSL virtual disk grows but does not shrink by itselfFix - 3
You compact the disk regularly and it fills up again.New virtual disks are not sparseFix
- 1
What does the error look like?
docker rm and docker rmi finish, but the C: drive stays fulldocker system df shows a large RECLAIMABLE size
Cause 1 of 3
Volumes, tagged images and build cache were not pruned
1Check
By default docker system prune removes stopped containers, unused networks, dangling images and unused build cache. It leaves volumes alone and keeps tagged images that are not dangling.
docker system df -v2Fix
Add --all to remove all unused images, and --volumes only when you are sure no volume holds data you need.
docker system prune --all
docker system prune --all --volumes3Verify
Run docker system df again; the reclaimable sizes drop.
docker system dfConfirmed by docs.docker.com
Cause 2 of 3
The WSL virtual disk grows but does not shrink by itself
1Check
WSL 2 stores its distributions in virtual hard disk files that resize automatically to meet storage needs. Deleting data inside does not by itself return the space to Windows. The compact step does: Optimize-VHD reclaims unused blocks, and needs the disk not attached or attached read-only.
wsl -l -v
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq '<distribution-name>' }).GetValue("BasePath")2Fix
Quit Docker Desktop, shut WSL down, then compact the disk file in an elevated PowerShell. Optimize-VHD comes with the Hyper-V PowerShell module.
wsl --shutdown
Optimize-VHD -Path "<path-to-the-vhdx-file>" -Mode Full3Verify
Check the size of the .vhdx file in Explorer or with Get-Item before and after.
(Get-Item "<path-to-the-vhdx-file>").Length / 1GBConfirmed by learn.microsoft.com
Cause 3 of 3
New virtual disks are not sparse
1Check
In .wslconfig, the experimental sparseVhd setting makes any newly created VHD sparse automatically. It is off by default and applies only to disks created after you turn it on.
type $env:USERPROFILE\.wslconfig2Fix
Enable the setting and restart WSL. Existing disks are not converted by it.
# %UserProfile%\.wslconfig
[experimental]
sparseVhd=true3Verify
Restart WSL, and check the setting is in the file.
wsl --shutdownConfirmed by learn.microsoft.com
How do I stop it coming back?
- Run docker system df now and then, and prune build cache on a schedule.
- Keep large data in named volumes that you remove on purpose, not in the container's writable layer.
- Take a copy of any volume you need before running prune with --volumes.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix