Last active
January 16, 2017 20:41
-
-
Save karantir/f2f420e8e2e2d43a6483a33d7e196e7d to your computer and use it in GitHub Desktop.
Remove exited containers, orphanted images and volumes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Docker version >= 1.9 | |
echo "Cleaning up exited containers..." | |
docker ps -a -qf status=exited | xargs -r docker rm | |
echo "Cleaning up orphanted images..." | |
docker images -qf dangling=true | xargs -r docker rmi | |
echo "Cleaning up orphanted volumes..." | |
docker volume ls -qf dangling=true | xargs -r docker volume rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment