After you build an image multiple times, the generated image tags consume the storage space of an Object Storage Service (OSS) bucket. Additional costs are incurred. Container Registry allows you to delete multiple image tags of Container Registry Enterprise Edition instances at a time. This topic describes how to configure a tag retention policy to delete multiple image tags at a time.
Configure a tag retention policy
After you configure a tag retention policy, the image tags that do not match the policy are deleted.
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 of the management page of the Container Registry Enterprise Edition instance, choose .
On the Tags page, click Create Retention Policy.
In the Create Retention Policy dialog box, configure parameters in the Cleanup Scope step and click Next. The following table describes the parameters.
Parameter
Description
Cleanup Scope
Valid values: Instance, Namespace, and Repository.
To delete image tags in an instance, select Instance. All repositories in the instance are cleaned up. Only the images of the specified tags in each repository in the instance are retained.
To delete image tags in a namespace, select Namespace. All repositories in the namespace are cleaned up. Only the images of the specified tags in each repository in the namespace are retained.
To delete image tags in a repository, select Repository and then select a namespace and a repository in the namespace. The specified image repository in the namespace is cleaned up.
NoteIf you select Repository and then only select a namespace and do not select a repository in the namespace, all repositories in the namespace are cleaned up.
Trigger Type
The execution method of tag deletion tasks.
Automatic: Container Registry automatically executes tag deletion tasks every week or every month.
Manual: You must manually execute tag deletion tasks. For more information, see Manually trigger tag deletion tasks.
Trigger Cycle
The execution cycle of tag deletion tasks. Valid values: Every Week and Every Month.
NoteYou need to set this parameter only when you set the Trigger Type parameter to Automatic.
In the Retention Policy step, configure parameters and then click Create Retention Policy. The following table describes the parameters.
Parameter
Description
Keep recently pushed images
This parameter is required. Set the number of recently pushed images that you want to retain.
Keep image tags
This parameter is optional. In addition to the number of the recently pushed images tags that you want to retain, you can use this parameter to specify the image tags that you want to retain.
NoteThe default value of this parameter is .*, which indicates that all image tags are retained in addition to the specified number of the recently pushed images.
Manually trigger tag deletion tasks
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 of the management page of the Container Registry Enterprise Edition instance, choose .
On the Tags page, find the retention policy that you want to apply and click Execute in the Actions column.
In the Tips message, click OK.
What to do next
After you delete image tags from a Container Registry Enterprise Edition instance, the image tags still occupy the storage space of OSS buckets. If you want to release the OSS storage space that is occupied by these image tags, execute artifact deletion tasks. For more information, see Clean up OSS buckets.