Recovering Disk Space Stolen by Docker

While docker commands like docker system prune reduce the space, that’s typically not where the disk usage comes from. The real culprits are the data volumes.

Docker on Windows doesn’t automatically reduce the disk size of the underlying VHDX volume – it only ever grows. So, for example, if you delete a large database in your Docker volume, Windows doesn’t actually recover the newly-freed space immediately. Over time you may find you eventually need to fix this manually.

This post describes how to optimize the VHDX file to reduce the disk usage to only what is actually required. Note that the Optimize-VHD command only is available when Hyper-V is enabled, and Hyper-V is only available on Windows 10 Pro, not Home.

If you still are low on space, it looks like there are unofficial ways of moving the VHDX volume to another drive, but I haven’t tested this.

Leave a comment

Your email address will not be published. Required fields are marked *