# Docker Image Cleanup Script Automatically clean up specific Docker images from your system. Originally designed for Pterodactyl game servers but easily customizable for any Docker images. ## Features - Targeted cleanup of specific Docker images - Force removal of stubborn images - Automatic container cleanup for images that can't be removed - Detailed logging of all operations - Configurable image patterns - Safe execution with proper error handling ## Installation 1. Clone the repository: ```bash git clone https://git.hhf.technology/hhf/docker-image-cleanup-general.git ``` 2. Make the script executable: ```bash chmod +x image-cleanup.sh ``` ## Usage Run the script as root: ```bash sudo ./image-cleanup.sh ``` ### Adding Custom Image Patterns Edit the `IMAGE_PATTERNS` array at the top of the script: ```bash IMAGE_PATTERNS=( "^hello-world" "pterodactyl" "pterodactyl/yolks" "ghcr.io/pterodactyl" # Add your patterns here ) ``` ### Automated Cleanup Add to crontab to run daily: ```bash 0 2 * * * /path/to/image-cleanup.sh ``` ## Logging Logs are stored in `/var/log/image-cleanup.log` View logs: ```bash cat /var/log/image-cleanup.log ``` ## Requirements - Docker - Root privileges - Bash shell ## Safety The script includes several safety measures: - Checks for Docker installation - Requires root privileges - Logs all actions - Attempts container cleanup before force removal ## License MIT License - See LICENSE file for details