Richard Bucker

Cleaning up after Docker

Posted at — Oct 27, 2014

I happen to be scanning my CoreOS boot drive and it’s 97% used.  CRAP! I have a number of ways to clean up my drives but in this case I had both active and dormant containers and so the usual way of cleaning this up was not going to work. The usual way was “delete everything that is not running; both containers and images”.Well that was not going to work… but then I was lucky too. I found these two commands here:docker ps -a | grep ‘weeks ago’ | awk ‘{print $1}’ | xargs –no-run-if-empty docker rmdocker images | grep “<none>” | awk ‘{print $3}’ | xargs docker rmiWhat makes these two commands interesting is actually the first.  It only deletes the containers that were  active “weeks ago”. Granted it’s possible to delete too much depending on the actual output of the docker command but in this case the data matched the query exactly.The other thing to note is that while docker seemed to delete all of the images… they were not actually deleted.  There is a btrfs_cleanup process that seems to be doing all of the heavy lifting… and my drive storage is returning to normal.