On my Windows 11 machine, I am running several containers formed from images that are updated regularly. I've connected the docker engine with WSL because that's where the images are built.
I noticed that the space on the hard disk that docker WSL uses doesn't shrink. Ever. Only a "purge data" command on docker desktop does seem to do the trick. But. This has a side benefit of removing all of my images and containers. Not that very nice.
If I run docker image prune -a
unnecessary images are purged, but the space is not reclaimed:
ronald@Ronald:~/$ docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: my.registry:somehash
deleted: sha256:somehash
...
Total reclaimed space: 0B
I've tried:
- Docker desktop restart. Does nothing.
- Shrinking the ext4.vhdx file with
diskpart
andOptimize-vhd
. Also doesn't shrink it.
So question: How do I tell docker to remove unused images without having to remove the images that I am using?