Skip to content

Instantly share code, notes, and snippets.

@h0tw1r3
Created February 21, 2023 21:45
Show Gist options
  • Save h0tw1r3/725a89819477d88776cbbabac804612a to your computer and use it in GitHub Desktop.
Save h0tw1r3/725a89819477d88776cbbabac804612a to your computer and use it in GitHub Desktop.
shell function to cleanup beaker docker containers
# 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