No description
Find a file
2024-12-06 23:00:25 +05:30
image-cleanup.sh Update image-cleanup.sh 2024-12-06 23:00:25 +05:30
README.md Add README.md 2024-12-06 22:17:21 +05:30

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:
git clone https://git.hhf.technology/hhf/docker-image-cleanup-general.git
  1. 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