Created
May 13, 2024 15:09
-
-
Save sovietspy2/a2d2d6628f53f315fb1f7b2b6f084c16 to your computer and use it in GitHub Desktop.
Bash script to delete all exited docker containers
This file contains hidden or 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 | |
# List all exited Docker containers | |
exited_containers=$(docker ps -a -f status=exited -q) | |
# Iterate over each exited container ID | |
for container_id in $exited_containers; do | |
echo "Deleting exited container: $container_id" | |
docker rm $container_id | |
done | |
echo "All exited Docker containers have been deleted." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment