-1

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 and Optimize-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?

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
hasdrubal
  • 1,024
  • 14
  • 30
  • looks like bug in docker https://github.com/docker/cli/issues/4028 – Rick Rackow Aug 17 '23 at 11:33
  • looks like, but not identical. I'm using docker image prune. Not docker volume prune – hasdrubal Aug 17 '23 at 12:03
  • Agreed, given this has been an issue in the past with windows for images https://github.com/moby/moby/issues/31253 and the recommendation was to open an issue, which just no one ever did, it seems, I'd recommend to do that. – Rick Rackow Aug 17 '23 at 12:27
  • Ah, my apologies - I marked as a duplicate even though you specifically said you had already tried the `optimze-vhd` option. Which image did you run that against? – NotTheDr01ds Aug 17 '23 at 18:44
  • ```C:\Users\user\AppData\Local\Docker\wsl\data\ext4.vhdx``` – hasdrubal Aug 18 '23 at 06:58
  • Please keep in mind that StackOverflow is a site for programming-related problems - to me, yours does not look like this. Also, all clarification should be added to the post itself, not to the comment section – Nico Haase Aug 18 '23 at 07:52
  • Lol, I challenge you to find any person who is ignorant of programming and has an understanding what we are discussing here. Programming is more than just coding. – hasdrubal Aug 18 '23 at 09:04
  • 2
    @hasdrubal A lot of folks don't consider general Docker Desktop questions to be on-topic since it is used for many purposes outside just programming. I tend to give more leeway to Docker Desktop personally, but I understand their viewpoint. I do close a lot of WSL questions that aren't specifically about programming. This one will be tough to get reopened because some of the close votes were due to it being off-topic. I'd suggest reposting on Super User, but also reference [this Super User question](https://superuser.com/q/1606213/1210833) so folks know you have already tried that. – NotTheDr01ds Aug 18 '23 at 17:02

0 Answers0