Created
March 27, 2021 16:28
-
-
Save lawrenceching/fbb9fa26202037617b37f3d736fb1358 to your computer and use it in GitHub Desktop.
Delete all exited 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
#!/bin/bash | |
containerIds=( $(docker container ls --all | grep Exited | cut -d ' ' -f 1) ) | |
length="${#distro[@]}" | |
if [ "0" = "$length" ]; then | |
echo "No exited container" | |
exit 0 | |
fi | |
for id in "${containerIds[@]}" | |
do | |
docker rm $id | |
echo "Deleted $id" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment