How to clean up Docker (~5GB junk!)

Image for post
Image for post
(Modified original image from Docker)

My 20GB DigitalOcean is consume 15.75GB of 19.56GB already! Note that I just finish setup Parse Server and only have 1 user record in MongoDB for testing which really mean 1 droplets never enough for real production.

But before we scale to another droplets, Maybe some cleanup could gain some space if we get lucky? Let’s try!


We’ll need some measuring tools. And after googling, I choose ncdu

Run ncdu at “/”

Image for post
Image for post

Explore /var/lib/docker

Image for post
Image for post
Docker is so fat 9GB!

Clean up unused Docker.

Let’s try first approach, some random script from googling.

And run (or DRY first) at your own risk.

Let’s see…

Image for post
Image for post

Not bad! We just save 1.3GB

Addition steps

Refer to this guide we’ve to…

Remove partial packages from the system.

Remove .deb packages that apt caches when you install/update programs.

Remove packages installed as dependencies after the original package is removed from the system.

And run ncdu at “/” again.


Image for post
Image for post

And now we got 13.6GB (from 15.4GB)which when we get around ~1.8GB back! Weeee!

Another attempt

We not done yet! after googling I found some more command to try…

Image for post
Image for post

Wow dangling! as you can see we just clean up 5.4GB of junk! Woooot!

Image for post
Image for post
volumes get slim

Phewww! This trick save my space which mean $$$ on DigitalOcean! (Sorry Digital Ocean’s team. I’ll paid you more for scaling but I’m not willing to paid for store 5.4GB of junk!) Now I can continue my Parse Server’s journey with more clean container :)

Note (ref)

Don’t miss a chance to get free $10 for DigitalOcean ← 2 months free hosting!
And do claim your cheapest .io name before it gone at NameCheap.

Happy Cleaning!

Written by

DLT & ML Debugger

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store