Scrounging around the issues in the docker project on github, I ran across a thread talking about solutions for the storage growth. I took it and expanded a bit.
Below is the output of past and present docker commands. Anything with a status of "Up for x minutes", those are presently running docker commands. Anything with Exit 0 or other Exit values are ended and can be discarded if they are not needed, such as you do not need to commit the changes to a new image. In the screenshot below, you can see a re-build of the mongodb image. There are two commands the Dockerfile issued that stored commits and they can be discarded.
$ sudo docker ps -a
TO DELETE UNUSED CONTAINERS:
$ sudo docker ps -a | grep 'Exit 0' | awk '{print $1}' | xargs docker rm
This will find any container with a "I have no error" exit status and delete them. Note: There may be other exit statuses depending on how well an image build went. If some of the commands issued in the Dockerfile are bad or fail, the status field will have a different Exit value, so just update the piped grep command with that string.
TO DELETE UNUSED IMAGES:
$ sudo docker images | grep 'none' | awk '{print $3}' | xargs docker rmi
No comments:
Post a Comment