Created
December 4, 2021 09:50
-
-
Save barthap/99308bcd22ff09f82bb75da9b92c0927 to your computer and use it in GitHub Desktop.
Remove dangling Docker images. Useful when you often use `docker compose pull` and your disk gets clogged with old images.
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 | |
set -euo pipefail | |
echo "These images are gonna be removed:" | |
docker images -f "dangling=true" | |
echo | |
read -p "Do you want to continue? [yN]" -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo "Removing dangling images..." | |
docker rmi $(docker images -f "dangling=true" -q) | |
echo "All done" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment