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
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.