Tuesday, July 5, 2022
HomeSoftware DevelopmentShrink your WSL2 Digital Disks and Docker Pictures and Reclaim Disk Area

Shrink your WSL2 Digital Disks and Docker Pictures and Reclaim Disk Area


Docker Desktop for Home windows makes use of SSL to handle all of your photographs and container recordsdata and retains them in a personal digital onerous drive (VHDX) known as ext4.vhdx.

It is normally in C:UsersYOURNAMEAppDataLocalDockerwsldata and you may typically reclaim a few of the area in the event you’ve cleaned up (pruned your photographs, and so on) with Optimize-Vhd below an administrator PowerShell shell/immediate.

You may have to cease Docker Desktop by proper clicking on its tray icon and selecting Give up Docker Desktop. As soon as it is stopped, you will wish to cease all working WSL2 situations with wsl --shutdown

Mine was 47gigs as I exploit Docker A LOT so once I optimize it from admin PowerShell from the wsldata folder

optimize-vhd -Path .ext4.vhdx -Mode full

…it’s now 2 gigs smaller. That is good, however it’s not a large enchancment. I can run docker photographs and see that many are outdated or previous. If I am not utilizing Kubernetes I can flip it off and delete these containers as nicely from the Docker settings UI.

I am going to run docker system prune -a to AGRESSIVELY tidy up. Examine these instructions earlier than your attempt your self. -a means all unused photographs, not simply dangling ones. Do not delete something you’re keen on or care about. If you happen to’re apprehensive, docker system is safer with out the -a.

Now my Docker WSL 2 VHD is 15 gigs smaller! Study extra about WSL, Home windows 11, and WSLg on my newest YouTube!

NOTE: Now you can get WSL from the Home windows Retailer! Go get it right here after which run “wsl –install” and your command line.

If you’d like, you can even go discover your Ubuntu and different WSL disks and Compact them as nicely. I solely take into consideration this a couple of times a yr, so do not think about this a significant cleanup factor until you are actually tight on area.

Ubuntu WSL disks will probably be in folders with names like




However it would be best to go searching for yours. Once more, again issues up and ensure WSL is shutdown first!

Get pleasure from! REMEMBER – You’ll want to again issues up earlier than you run instructions as admin from some random individual’s weblog. Have a plan.

Sponsor: YugabyteDB is a distributed SQL database designed for resilience and scale. It’s 100% open supply, PostgreSQL-compatible, enterprise-grade, and runs throughout all clouds. Join and get a free t-shirt!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, marketing consultant, father, diabetic, and Microsoft worker. He’s a failed stand-up comedian, a cornrower, and a guide creator.

About   Publication

Internet hosting By
Hosted in an Azure App Service




Most Popular

Recent Comments