Created
February 2, 2026 13:35
-
-
Save ragnarok22/cd0b1317fea78140117af9adcb09d388 to your computer and use it in GitHub Desktop.
Clean up unused Docker resources (containers, networks, volumes, images, and build cache)
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
| #!/usr/bin/env bash | |
| # clean-docker.sh | |
| # Description: Clean up unused Docker resources (containers, networks, volumes, images, and build cache) | |
| # | |
| # Usage: | |
| # chmod +x clean-docker.sh | |
| # ./clean-docker.sh | |
| # | |
| # Or run directly with: | |
| # curl -sL <raw-url> | bash | |
| set -euo pipefail | |
| echo "==> Removing stopped containers..." | |
| docker container prune -f | |
| echo "==> Removing unused networks..." | |
| docker network prune -f | |
| echo "==> Removing unused volumes..." | |
| docker volume prune -f | |
| echo "==> Removing dangling images..." | |
| docker image prune -f | |
| echo "==> Removing build cache..." | |
| docker builder prune -f | |
| echo "==> Disk usage after cleanup:" | |
| docker system df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment