Last active
August 14, 2018 03:34
-
-
Save tebeka/ab6c480ea736d9a16655761e82d48eea to your computer and use it in GitHub Desktop.
Cleanup Docker
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 | |
# Cleanup docker containers and volumes | |
case $1 in | |
-h | --help ) echo "usage: $(basename $0)"; exit;; | |
esac | |
if [ $# -ne 0 ]; then | |
1>&2 echo "error: wrong number of arguments" | |
exit 1 | |
fi | |
docker ps -a --filter status=exited --format {{.ID}} | xargs -i docker rm {} | |
docker images -f dangling=true -q | xargs -i docker rmi {} | |
docker volume ls -q -f dangling=true | xargs -i docker volume rm {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment