Created
April 12, 2024 23:29
-
-
Save SamuelDavis/c66099f2fb5b3ebfec646cc5901f6fdb to your computer and use it in GitHub Desktop.
useful docker functions
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
docker-prune () { | |
for CMD in "$@" | |
do | |
echo "Pruning ${CMD}s..." | |
IDS=$(docker $CMD ls --all --quiet 2> /dev/null || docker $CMD ls --quiet) | |
[ -z "$IDS" ] && echo "None found." && continue | |
echo "$IDS" | xargs -L1 docker $CMD rm --force | |
docker $CMD prune --force | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment