After using docker desktop for quite long time it take disk space up to 50 GB or more for it's cache objects, images & junkey files. To Reclaim disk space there are some few steps to follow :
# Before cleaning docker cache object see your existing docker system details
>> docker system info
# Now clean all caches it takes around 30 sec or less
>> docker system prune --all
# then you will got
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
# Give permission & wait.
# This Operation will be end with this line in my case I got 7 GB after using one week of docker desktop.
>> Total reclaimed space: 7.027GB ( I got 7GB )
# Now You need to stop WSL for compact it.
Firstly Open Powershell as Administrator
# Go to wsl's docker folder in AppData by
>> cd C:\Users\YOUR_USERNAME\AppData\Local\Docker\wsl\data
# Inside it run this command
>> optimize-vhd -Path .\ext4.vhdx -Mode full [IF THIS IS FAILED TRY BELLOW'S COMMAND]
>> Optimize-VHD -Path .\ext4.vhdx -Mode Full
# It will take around 15/20 sec . In my pc it claim more than 3GB.
So after doing these steps 'Restart Docker'. That's all. Enjoy.
If it help, don't forget to give start 😎