No description
image-cleanup.sh | ||
README.md |
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
- Clone the repository:
git clone https://git.hhf.technology/hhf/docker-image-cleanup-general.git
- Make the script executable:
chmod +x image-cleanup.sh
Usage
Run the script as root:
sudo ./image-cleanup.sh
Adding Custom Image Patterns
Edit the IMAGE_PATTERNS
array at the top of the script:
IMAGE_PATTERNS=(
"^hello-world"
"pterodactyl"
"pterodactyl/yolks"
"ghcr.io/pterodactyl"
# Add your patterns here
)
Automated Cleanup
Add to crontab to run daily:
0 2 * * * /path/to/image-cleanup.sh
Logging
Logs are stored in /var/log/image-cleanup.log
View logs:
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