Remove Docker related files

Jun 03, 2020

If you find your hard drive is running out of space and use docker, you might want to try the following series of commands before heading out and buying an external storage for your laptop:

docker system prune -a

docker volume prune -f

I have been struggling to free up storage on my Macbook's hard drive for a while now as it only has 256GB.  I was at about 5GB free, I managed to delete some github repositories and files and ended up with 30GB free.  I recalled that docker is a space hog and have used a purged command in the based on an Ubuntu server I was managing, so I looked up the command and after a long wait (the process took a good while to complete) I was at 60GB free!

Docker's philosophy is:

Docker takes a conservative approach to cleaning up unused objects (often referred to as “garbage collection”), such as images, containers, volumes, and networks: these objects are generally not removed unless you explicitly ask Docker to do so.  

Reference doc

I haven't tried this myself but it looks like the above 2 commands are combined if you do:

docker system prune --volumes

Hopefully your computer can breathe a little better now.

Salman Ahmed

Toronto based Software developer

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.