Image tags from repeated builds consume Object Storage Service (OSS) bucket storage and increase costs. Tag retention policies let you specify which image tags to keep and delete the rest across an Enterprise Edition instance.
Tag retention policies are available only for Container Registry Enterprise Edition instances.
Prerequisites
A Container Registry Enterprise Edition instance. For details, see Container Registry editions.
Permissions to manage the instance.
Create a tag retention policy
A tag retention policy keeps image tags that match the policy and deletes all others.
Log on to the Container Registry console.
In the top navigation bar, select a region.
In the left-side navigation pane, click Instances.
On the Instances page, click the Enterprise Edition instance that you want to manage.
In the left-side navigation pane, choose .
On the Tags page, click Create Retention Policy.
In the Create Retention Policy dialog box, configure the Cleanup Scope parameters and click Next.
Parameter
Description
Cleanup Scope
The scope of repositories to clean up. Valid values: Instance, Namespace, and Repository. See the following table for details.
Trigger Type
The method for running tag deletion tasks. Valid values: Automatic (runs on a recurring schedule) and Manual (requires you to manually run the task). For more information, see Manually run a tag deletion task.
Trigger Cycle
The schedule for automatic tag deletion. Valid values: Every Week and Every Month. Configure this parameter only when Trigger Type is set to Automatic.
Cleanup Scope values:
Value
Behavior
Instance
Cleans up all repositories in the instance. Only image tags that match the retention policy are kept in each repository.
Namespace
Cleans up all repositories in the selected namespace. Only matching image tags in each repository are kept.
Repository
Cleans up a single repository. Select a namespace, then select a repository in the namespace.
NoteIf you select Repository as the cleanup scope but select only a namespace without selecting a specific repository, all repositories in the namespace are cleaned up.
In the Retention Policy step, configure the following parameters, and then click Create Retention Policy.
Parameter
Required
Description
Keep recently pushed images
Yes
The number of recently pushed images to retain.
Keep image tags
No
A regex pattern that specifies additional image tags to retain. The default value is
.*, which retains all image tags in addition to the specified number of recently pushed images.
Manually run a tag deletion task
If the trigger type is set to Manual, or if you want to run an automatic policy ahead of schedule, trigger the task manually.
Log on to the Container Registry console.
In the top navigation bar, select a region.
In the left-side navigation pane, click Instances.
On the Instances page, click the Enterprise Edition instance that you want to manage.
In the left-side navigation pane, choose .
On the Tags page, find the retention policy and click Execute in the Actions column.
In the Tips message, click OK.
What to do next
Deleted image tags still occupy OSS bucket storage. To release the storage space, run artifact deletion tasks. For more information, see Clean up OSS buckets.