Docker Registry Image Tag Periodic Cleanup Workflow
This workflow automates the management of tags in the Docker image repository by regularly scanning and deleting expired or redundant tags, while retaining only the latest few and the "latest" tag, thereby keeping the repository tidy. After the cleanup, garbage collection is performed, and the operations team is notified of the results via email, with support for failure alerts. This enhances operational efficiency and space utilization, addressing issues of wasted storage resources and management chaos.

Workflow Name
Docker Registry Image Tag Periodic Cleanup Workflow
Key Features and Highlights
This workflow automates the management of image tags in a Docker image registry by periodically scanning all images and their tags. It intelligently identifies and deletes expired or redundant tags, retaining only the latest several tags along with the “latest” tag to ensure a clean and organized repository. After cleanup, it automatically performs garbage collection and sends email notifications to operations personnel regarding the results. It supports failure alerts, thereby improving operational efficiency and optimizing repository storage utilization.
Core Problems Addressed
- Accumulation of tags in the Docker image registry causing storage waste and management complexity
- Manual cleanup is cumbersome and prone to errors
- Lack of automated alerting and post-cleanup garbage collection mechanisms
Application Scenarios
- Enterprises or teams using private Docker image registries requiring regular maintenance of image tags to prevent storage bloat
- DevOps engineers automating image management to enhance operational automation
- Cloud platforms and continuous integration environments for image version management and optimization
Main Process Steps
- Scheduled Trigger: Automatically start the cleanup process daily at 1:00 AM
- List All Images: Retrieve the list of images from the Docker Registry
- Extract Image Names: Parse the image list and process each image individually
- Fetch Image Tags: Retrieve all tag information for each image
- Split Tags: Break down the tag list into individual tag entries
- Filter Valid Tags: Remove invalid or empty tag data
- Get Tag Details: Use API calls to obtain the Manifest and creation time for each tag
- Sort and Group: Sort tags by creation time in descending order and group by image name
- Identify Tags to Delete: Retain the latest 10 tags plus the “latest” tag; mark others for deletion
- Delete Old Tags: Remove expired tags via DELETE requests
- Perform Garbage Collection: Execute the Registry’s garbage collection command remotely via SSH
- Send Notification Emails: Notify operations staff of success or failure via email
Involved Systems or Services
- Docker Registry HTTP API (for image and tag operations)
- SMTP Email Service (for sending notification emails)
- SSH Service (for remote execution of garbage collection commands)
- n8n Automation Platform (for scheduling and workflow orchestration)
Target Users and Value
- DevOps engineers and operations teams, helping them automate Docker image management to save time and reduce labor costs
- Enterprise IT departments, enhancing resource utilization and governance of image registries
- Development teams, ensuring a clean image environment and preventing deployment issues caused by excessive tags
- Any organization managing images with private Docker Registries, significantly reducing maintenance complexity and operational risks
This workflow enables users to automate the cleanup and maintenance of image tags, preventing long-term accumulation that leads to wasted space and management difficulties. It ensures the retention of critical tags and timely alerts, greatly enhancing the automation and reliability of Docker image registry management.