Tencent Container Registry (TCR) supports the hosting and distribution of container images and provides the image building feature to enable image building, push, and hosting to be automatically triggered by code changes. If customers need to quickly iterate their applications, they can adopt an automated pipeline to generate images. Large number of image tags will be generated continuously, and the old image tags will no longer be used. If a single image repository contains too many image tags, the burden of tag management is huge, and the quota of image tags in the repository will be used up. Therefore, TCR provides the image tag retention feature to allow users to create custom rules for tag retention. Such rules can be triggered periodically to automatically delete the image tags that fall outside the retention scope.
Tag retention rules support two types of retention policies: retaining the latest # tags pushed and retaining the tags pushed within # days, and simulated execution is supported. Additionally, in advanced configuration mode, you can filter repositories and tags, and combine them with the two retention policies to achieve more flexible and precise tag management.
Supports and Limits
1. The tag retention feature will delete image tags that fall outside the retention rules.
2. The tag retention feature only deletes image tag information, but not the underlying image data. To thoroughly clean up image data, please use the garbage collection feature for COS storage.
3. The advanced configuration mode is currently in beta. To use the advanced configuration mode, please submit a ticket.
Instructions
Creating tag retention rules
1. Log in to the Container Registry console and select Tag Retention from the left navigation bar. On the "Tag Retention" page, you can view the list of tag retention rules within the current instance. If you need to switch instances, please select from the "Instance Name" dropdown list at the top of the page.
2. Click on Create Rule, in the "Create tag retention rules" window, refer to the following prompts for rule configuration. You can choose between two configuration modes:
Basic Configurations
Advanced Configurations
Associated instance: Currently selected instance.
Namespace: Namespace for which the tag retention rule will take effect. Currently, only one rule can be created for a single namespace.
Configuration mode: Basic Configuration
Retained tags: By default, all repositories and tags in the namespace are retained and no filter is applied.
Retention rules: You can choose between retaining the most recently pushed # tags and retaining the tags pushed within the last # days, and specify the number of tags or days accordingly.
Execution period: The cycle for implementing the tag retention rule, which supports manual execution, or daily, weekly, and monthly execution. The specific execution times are as follows: daily execution is at midnight, weekly execution defaults to midnight on Monday, and monthly execution is at midnight on the first day of the month.
Rule switch: By default, the rule is enabled.
Associated instance: Currently selected instance.
Namespace: Namespace for which the tag retention rule will take effect. Currently, only one rule can be created for a single namespace.
Configuration mode: Advanced Configuration
Retention rules: Multiple retention rules can be configured, and the rules are combined using the union operation. That is, an image tag will be retained if it meets any of the retention rules.
Repository filter: Supports matching or excluding specific repositories by using regex to filter repository names. "" and "" can match any length of strings, but "" does not support matching multi-level repository names. "?" matches any single character except "/". For more matching rules and scenarios, click here.
Tag filter: Supports matching or excluding specific tags within a repository by using regular expressions to filter tag names, following the same rules as repository filtering.
Retention rule: You can choose between retaining the most recently pushed # tags and retaining the tags pushed within the last # days, and specify the number of tags or days accordingly.
Execution period: Cycle for executing the tag retention rule. Manual, daily, weekly, and monthly execution are supported.
Rule switch: By default, the rule is enabled.
3. Click Confirm to create the tag retention rule.
Managing tag retention rules
Once the tag retention rule is successfully created, you can view the created rules on the "Tag retention" page. You can perform the following operations to manage the tag retention rules, as shown in the figure below:
View the rule execution logs: You can click the name of a rule to view its triggering logs. For more information, see Viewing execution logs.
Configuration: You can reconfigure a tag retention rule but cannot modify the namespace for which it takes effect.
Delete: Remove the tag retention rule for the instance.
Viewing execution logs
1. Click the name of the target tag retention rule to view the triggering logs of the rule:
Task ID: ID of a tag retention task, unique within the instance.
Creation Time: Time when a tag retention task was created.
Time Spent: Time consumed to complete all the tag retention tasks.
Execution Method: Manual or automatic. Clicking "Execute Now" or "Simulate Execution" is the manual method, while automatic execution is performed according to the cycle defined by the rule.
Execution Type: Real execution or simulate execution. Simulate execution can be used to confirm whether the rule is effective, but it does not actually clear image tags.
Execution Status: Status of task completion.
2. You can click a task ID to view the task details and click a specific repository to view its execution log.