Container Registry allows you to delete multiple image tags of a Container Registry Enterprise Edition instance at a time. This topic describes how to delete multiple image tags at a time by configuring a tag retention policy.

Configure a tag retention policy

After you configure a tag retention policy, the image tags that do not match the policy are deleted.

  1. Log on to the Container Registry console.
  2. In the top navigation bar, select a region.
  3. On the Instances page, click the required Container Registry Enterprise Edition instance.
  4. On the management page of the Container Registry Enterprise Edition instance, choose Repository > Tags in the left-side navigation pane.
  5. On the Tags page, click Create Retention Policy.
  6. In the Create Retention Policy dialog box, set the parameters in the Cleanup Scope step and click Next.
    Parameter Description
    Cleanup Scope You can delete image tags in an Instance, a Namespace, or a 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 all repositories 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 all repositories 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.
      Note If 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 image cleanup tasks.
    • Automatic: Container Registry automatically executes image cleanup tasks every week or every month to delete image tags.
    • Manual: You must manually execute image cleanup tasks. For more information, see Manually trigger image cleanup tasks.
    Trigger Cycle The execution cycle of image cleanup tasks. Valid values: Every Week and Every Month.
    Note You must set this parameter only when you set the Trigger Type parameter to Automatic.
  7. In the Retention Policy step, set the parameters and click Create Retention Policy.
    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 specify the image tags that you want to retain by using this parameter.
    Note The 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 image cleanup tasks

  1. Log on to the Container Registry console.
  2. In the top navigation bar, select a region.
  3. On the Instances page, click the required Container Registry Enterprise Edition instance.
  4. On the management page of the Container Registry Enterprise Edition instance, choose Repository > Tags in the left-side navigation pane.
  5. On the Tags page, find the retention policy that you want to apply and click Execute in the Actions column.
  6. 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 Object Storage Service (OSS) buckets. If you want to release the OSS storage space that is occupied by these image tags, execute artifact cleanup tasks. For more information, see Release the storage space of OSS.