Created
June 5, 2018 20:58
-
-
Save erpalma/afdb15b18e91e5e73ff2afa61cfd395b to your computer and use it in GitHub Desktop.
Cleaning up some docker mess
This file contains 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 | |
echo "Cleaning unused docker files..." | |
docker ps --all --quiet --filter="status=exited" | xargs --no-run-if-empty docker rm --volumes | |
IMAGES=`docker images | awk '/^<none>/ { print $3 }'` | |
if [[ $IMAGES ]]; then | |
echo -e "\nCleaning untagged images..." | |
docker rmi --force $IMAGES | |
fi | |
VOLUMES=`docker volume ls --quiet --filter="dangling=true"` | |
if [[ $VOLUMES ]]; then | |
echo -e "\nCleaning volumes..." | |
docker volume rm $VOLUMES | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment