From 57262655c97fc562ff1ea2b1fc8aba66c648e19f Mon Sep 17 00:00:00 2001 From: hhf Date: Fri, 6 Dec 2024 22:17:21 +0530 Subject: [PATCH] Add README.md --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1eab495 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# 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 \ No newline at end of file