Remove Old Docker Images

One of the quirks I've found is Docker never cleans up it's self

Jack Liddiard

1 minute read

Don’t get me wrong I like Docker, but my god it has some flaws.

One of them is it keeps taking down our continues integration server (gocd) every few months because it hogs all the disk with unused and old images.

One of the quirks I’ve found is Docker never cleans up it’s self


docker images -q | xargs -r docker rmi

What’s Happening?

So what an earth is happening?

docker images will list you all the images in your docker instance: * -q will only show numeric IDs

xargs is one of my favourite, it will build and execute a command lines from standard input * -r will not run the command if the standard input does not contain any nonblanks.

docker rmi will remove one or more images

comments powered by Disqus