Running out of space because of docker containers / images?

Almost 3 years ago I published a much-needed post around cleaning up space taken by docker (it’s been one of the most popular posts on this blog according to Google Analytics), but since a year or so there’s a much better way to achieve the same.

Disk space has been one of the biggest painpoints for whoever worked with docker: you build containers, run them and don’t bother cleaning them up :) Images, build caches and container filesystems pile up and, before you know it, there’s some 50GB of space taken by docker.

Luckily enough, the docker CLI now has a very simple way to free space taken by images / containers:

1
2
3
4
5
6
7
8
9
10
11
$ docker system prune

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache
Are you sure you want to continue? [y/N]

...
Total reclaimed space: 513.6MB

The disadvantage of this approach is that it actually kills a few things you might be interested in (build caches, for example), but it’s one of those instructions each and everyone of us should dump in the crontab of our servers, or run seldom on a local machine.

Adios!


Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $9.99

In the mood for some more reading?

...or check the archives.