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.

Tags

Docker CleanupImage Tagging

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

  1. Scheduled Trigger: Automatically start the cleanup process daily at 1:00 AM
  2. List All Images: Retrieve the list of images from the Docker Registry
  3. Extract Image Names: Parse the image list and process each image individually
  4. Fetch Image Tags: Retrieve all tag information for each image
  5. Split Tags: Break down the tag list into individual tag entries
  6. Filter Valid Tags: Remove invalid or empty tag data
  7. Get Tag Details: Use API calls to obtain the Manifest and creation time for each tag
  8. Sort and Group: Sort tags by creation time in descending order and group by image name
  9. Identify Tags to Delete: Retain the latest 10 tags plus the “latest” tag; mark others for deletion
  10. Delete Old Tags: Remove expired tags via DELETE requests
  11. Perform Garbage Collection: Execute the Registry’s garbage collection command remotely via SSH
  12. 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.

Recommend Templates

Eventbrite Order Status Real-Time Trigger

This workflow automatically captures events such as order creation, updates, and refunds by real-time monitoring of the order status changes in Eventbrite. Once a change occurs, the system immediately triggers subsequent automated actions to ensure timely response and processing of order data. This real-time monitoring mechanism significantly enhances order management efficiency, helping event organizers, marketing teams, and finance departments quickly respond to order dynamics, thereby optimizing customer service and financial processes.

Eventbrite TriggerOrder Monitoring

Public Webhook Relay

This workflow receives external POST requests through a public Webhook and automatically forwards them to local processes. It periodically polls for new requests, automatically manages authorization tokens and request statuses, ensuring reliable data transmission. Users can securely receive and process Webhook notifications in a local environment without the need to set up a public server, making it suitable for various scenarios such as development, testing, and data forwarding, significantly improving work efficiency and lowering technical barriers.

Webhook Relayn8n Integration

Multi-File Download and Merge Example Workflow

This workflow enables the automatic batch download of multiple specified URL files and merges the individual binary file data into a unified data item, simplifying the file processing process. By manually triggering the workflow, users can conveniently download the required resources, avoiding the inefficiencies and error risks associated with downloading files one by one. It is applicable in various scenarios such as marketing, content management, and data analysis, significantly enhancing work efficiency.

file downloadbatch merge

Workflow Importer

This workflow enables the automatic import of workflows from local files or remote instances. It supports reading and parsing JSON format files, simplifying the migration process across instances or from local files. Users can select the target workflow and manage credential mapping to ensure the validity and security of the imported credentials. The workflow provides instant feedback, enhancing the user experience, and is particularly suitable for team collaboration, workflow sharing, and batch import scenarios, effectively reducing the risks associated with manual operations.

workflow importn8n migration

Sse Automation Triggered

This workflow uses an SSE (Server-Sent Events) trigger to receive event pushes from a specified URL in real-time. It is designed to continuously listen for server events and respond automatically, making it suitable for scenarios that require real-time data updates. The process is straightforward, consisting of only one SSE trigger node, making it ideal for developers, operations personnel, and business teams looking to automate responses to external events. Overall, this workflow helps build real-time monitoring and event-driven automation processes, enhancing response speed and operational efficiency, and can be further expanded to achieve complex automation task chains.

SSE TriggerReal-time Monitoring

n8n Subworkflow Dependency Graph & Auto-Tagging

This workflow automatically analyzes and constructs a dependency graph between workflows, helping users identify the callers of sub-workflows and automatically tagging them. Through visual charts, users can intuitively understand the call frequency and structure between workflows, reducing maintenance costs and preventing operational errors. At the same time, this workflow is suitable for teams and enterprises managing complex automation processes, enhancing workflow management efficiency and ensuring the stability and healthy development of processes.

n8n workflowdependency graph

Backup to GitHub

This workflow automatically backs up all workflow configurations to a specified GitHub repository, ensuring data security and version control. Triggered either on a schedule or manually, the workflow processes configuration files one by one, checking for differences with the files on GitHub and performing the corresponding create or update operations. This process effectively manages workflows, prevents data loss, and saves storage resources, making it suitable for teams and individuals that require regular backups and version management.

n8n BackupGitHub Sync

GitHub Repository Update Triggered Smart Lighting Alert

This workflow enables automatic switching of lights to red through a smart home system when updates occur in a GitHub repository. This physical feedback allows team members to instantly notice code changes, avoiding the neglect and delays associated with traditional notification methods, thereby enhancing response efficiency. It is suitable for software development teams, individual developers, and tech enthusiasts, enhancing the integration of work with smart home environments and improving collaboration and management efficiency.

GitHub AlertsSmart Home