Docker Desktop WSL2 — VHDX grows by ~1.5GB after every update, no way to reclaim space

I’m not sure why the data disk grows when the Desktop gets an update. It has its own disk. Maybe there is an upgrade proces that changes docker agent data like its own databases.

My guess is that your problem is that Docker Desktop cannot handle directly how filesystem is written and it is written randomly on the whole available disk. Since WSL will create a huge virtual disk (maybe the size of your phyisical disk? I don’t remember) it can make the disk bigger every time it writes a new sector.

We noticed it with Docker Sandbox on new MacBooks first where the disk is also SSD.

There is also a link to an issue on Github in the topic, but not really active and that is for Docker Sandbox which uses microVMs. I don’t know how it could be fixed in WSL. Until there is a better way, you can check if this works for you

The difference compared to what you tried is likely that you ran fstrim, but didn’t trim the disk itself. The sparse flag would only mean that the newly created disks are created as sparse files, but that wouldn’t help and I don’t understand why the WSL documentation says sparse is not the default. As far as I know, it just means a 1TB disk will not phisically be 1TB on the host and only uses as much space as it is used inside the virtual disk on the filesystem. That is how it works now for you anyway if I understand it correctly.