Docker Community Forums

Share and learn in the Docker community.

Removal of image, does not frees up disk space

I’ve removed an image with docker rmi, also used docker system prune, but actually not a byte is freed.
As i see this bug isn’t fixed since years.
How can i free up the space?

For me docker system prune -a works like a charm.

it works for me too, just frees up nothing

The -a option wipes everything- that is not currently referenced by containers - clean on my systems.

Though, I am only using docker from docker’s repos, as I find other docker distributions from other maintainer typicaly to provide undesired surprises, for instance like the snap package (which is basicly broken).

yes it is wipes everything from docker, but not from the disk…

:blush: I have missed the forum category your post is in “Docker Desktop for Windows”.

So your problem is not with how Docker works, but with how Docker Desktop for Windows interacts with it’s vm it requires to run docker inside. This is the case for Hyper-V or WSL2, which both store their data in virtual disk images (vhdx files).

When pruning or deleting any kind of docker object, you expect it to free up space on your host.

I am afraid this is a constraint of Hyper-V or WSL2: you can not shrink a vhdx while running the vm that uses it. It is technicaly impossible that any docker command will ever be able to run commands that need the vm to be stopped first, in order to instruct host operations to shrink the vhdx.

I do use WSL2 (without DDfW) and I know the problem of an always growing vhdx files. I shrink mine manualy with commands on the command line.

1 Like

shring by which command? From where? From the wsl, or the host command line?

Sure, no problem.I can google it for you, search terms: wsl shrink
First result: How to Shrink a WSL2 Virtual Disk – Stephen's Thoughts

1 Like