Created
February 21, 2023 21:45
-
-
Save h0tw1r3/725a89819477d88776cbbabac804612a to your computer and use it in GitHub Desktop.
shell function to cleanup beaker docker containers
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
# clean up all beaker containers and images | |
# useful when using BEAKER_destroy=no | |
function docker-cleanup-beaker() { | |
while read i; do | |
X=($i) | |
echo -n "Cleaning up ${X[2]}: stopping container" | |
docker stop "${X[0]}" >/dev/null | |
echo -n ", removing container" | |
docker rm "${X[0]}" >/dev/null | |
echo -n ", removing images" | |
docker image rm "${X[1]}" >/dev/null | |
echo "." | |
done < <(docker ps -a --filter 'name=beaker-' --format '{{.ID}} {{.Image}} {{.Names}}') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment