For those of you that run Docker Desktop on Windows with WSL2 integration, this is for you..
Have you wondered where all your hard drive space is going? Have you seen that the folder c:\users\<yourname>\AppData\Local\Docker\WSL\Data is growing and never shrinking?
Well in that folder sits a virtual hard disk called ext4.vhdx, and its the virtual disk that the Docker Desktop WSL2 instance uses. This is a "thin provisioned" disk image that grows as data is created, but its never compacted again, even if the data is removed from within the virtual disk itself (so doing docker system prune commands wont actually get you back any space).
Just this morning my own laptop ran out of disk space (as in 0 bytes free), and a quick check showed me that my docker desktop VHDX was at 41GB.
A quick google search lead me to this blog: https://nickjanetakis.com/blog/reclaiming-tons-of-diskspace-by-compacting-your-docker-desktop-wsl-2-vm which saved my bacon.
I ran the commands he recommended (shown below), and managed to reclaim 5GB of space. Not a lot, i know, but got me out of a hole.
The root cause isnt actually Docker's issue (its WSL2), but no idea why Docker dont make this quick fix a "right click" option off their task bar icon, or even an option in their settings menu. It seems like a pretty important thing to do, especially with highly dynamic environments like local developers using Docker Desktop (the target market..
Anyway, thought this might be a useful piece of info, and thanks to Nick Janetakis for making this fix easy to find.
Here is the root cause if its of interest.. note its been open since Nov 2019. https://github.com/microsoft/WSL/issues/4699