Docker & WSL Hogging C Drive
My laptop computer has solely 147 GB of area and run Home windows 10 as my C Drive. Now any developer who makes use of many software program as a part of their development course of would agree that this area is grossly insufficient.
I needed to uninstall and consistently clear up my drive to have sufficient usable disk area to do something. In final month I reached virtually few hundred mb of area and stuffed out my arduous drive.
I knew one thing drastic needed to be finished until I reformat my c drive. I’ve to aggressively search for the culprits and discover alternate options for them. And that’s after I got here throughout TreeSize Free as an answer to scan my drive and checklist the information and folders which are hogging my area. And the outcomes have been phenomenal. I had used such apps in my android telephone however have averted utilizing it on my Home windows laptop.
TreeSize Free could be very straightforward to make use of since I had no disk area left I downloaded a transportable model extracted on one of many different spare drives. And ran this system. The UI could be very easy. There’s a folder icon
Choose Listing . There’s a drop down below this icon which permits to pick out the drive and I selected my C drive and began the scan. Then it asks if I want to scan as Admin which I needed to in order to search out all of the potential information & folders which are hogging my disk area.
Surprisingly the largest information have been 32 & 8 GB all being vhdx photographs (digital disk photographs utilized by the hyper-v) being utilized by Docker desktop which had the wsl integration enabled & wsl itself. Now I needed to discover a resolution how can I transfer these information to another drives to get some further area. It was dangerous as I used to be unsure of the corruption dangers and making wsl and Docker Desktop unusable which I’ve been utilizing extensively not too long ago.
After some analysis I discovered the answer which helped me rather a lot. And once more SO got here to the rescue, with this link .
Listed here are the steps:
- Cease Docker Desktop
- Cease wsl
- Export Docker Desktop disk to an exterior Drive
For this I switched to my D drive which has 350 gb of information and ran the next command
wsl --export docker-desktop-data docker-desktop-data.tar
- Unregister Docker Desktop from wsl
On this step principally I unregisted Docker Desktop as a distribution from wsl which handles the persistence and container administration for Docker
wsl --unregister docker-desktop-data
- Lastly re-created the Docker Desktop with wsl with the import of exported Docker Desktop digital drive from the brand new path.
wsl --import docker-desktop-data D:docker-new-repo docker-desktop-data.tar --version 2
D:docker-new-repo this path signifies that now the vhdx file can be extracted to this new path.
- To test if the import ran nice you’ll be able to test operating the next command
wsl -l --all --verbose pattern output: docker-desktop Stopped 2 docker-desktop-data Stopped 2
As a facet notice, earlier than I did this I took backup of my required docker photographs. Additionally eliminated all photographs and containers earlier than continuing which the export and import of the vhdx
To delete all containers together with its volumes use,
docker rm -vf $(docker ps -a -q)
To delete all the pictures,
docker rmi -f $(docker photographs -a -q)
I used to be capable of delete the unused vhdx information from C drive and save important quantity of area. Additionally after I began my Docker Desktop I didn’t discover any points. This was a fast hack which helped me I’m positive this can assist others as properly. Am but to take away my wsl however the course of is analogous. If it’s essential do this your self please test the references. And if you wish to focus on additional please do remark or ship me a mail bobquest33(at)gmail(dot)com.
Checkout extra Articles on Sayed.CYou