Clean up docker containers and images

For some reason, docker is not that friendly to disk space and different applications may have different issues in terms of cleaning up old stale docker containers and images. When docker directory is filling up, your application would die. So keep an eye on the disk utilisation of docker partition is very critical. You shall monitor this by either scripting or third party monitoring tool.

Try the below commands, they are tested on CentOS 7 with docker: 1.5.0 , build a8a31ef

  1. docker images | grep “<none>”

find out the image ID, then run docker rmi $imageID

2.  docker rm `docker ps -a | grep Exited | awk ‘{print $1 }’`

3.  If your application is running, it is safe to use the following as well, do not run this when your application service is not

running, a good practice is to take a snapshot if you are uncertain about the results.

docker rmi `docker images -aq`

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s