A common issue I’ve ran into when running Docker Desktop on Windows is a virtual drive consuming a large amount of disk space. If the common methods of reducing the disk space used by Docker yield no results, you can take some extra measures.
Hopefully it goes without saying, you should regularly run the below command to get rid of any dangling and unused images eating up disk space:
docker system prune -a
If you still notice a vhdx
file using a considerable amount of disk space, you can run the following commands in a command prompt to shrink the vhdx
file:
> wsl --shutdown
> diskpart
DISKPART> select vdisk file="<path to vhdx file>"
DISKPART> compact vdisk
DISKPART> exit
This will reduce the space on your vhdx
file to the amount of space it truly needs. Running this in the past, I’ve seen up to a 90 percent reduction in the size of this file. Hopefully you see similar results.