This post is simply here to document how to remove untagged and exited images and containers.
You can find previously exited images by using filters:
This will return the full text for each exited container:
To remove all of them, you can nest a command similar to the one above inside the docker rm command:
Docker responds with a list of IDs that it deleted:
If you wish to clean up untagged instances you can find them with another filter command, similar to the one above:
This will return a formatted list of the untagged images:
And again, nesting a variation of that command to actually do the cleanup:
Now something interesting happens!
If the images are in use by some container, you must first stop the container. You’ll have to resolve this in order to remove this image. This is a good thing though, it can keep you from blowing yourself up :)