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

Prerequisites

The permission to use this feature is granted to you after you submit a ticket in the submit a ticket.

Configure a retention policy

After you configure a retention policy, the image versions 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. In the left-side navigation pane, click Instances.
  4. On the Instances page, click the required Container Registry Enterprise Edition instance.
  5. On the management page of the Container Registry Enterprise Edition instance, choose Repositories > Version Management in the left-side navigation pane.
  6. On the Version Management page, click Create Retention Policy.
  7. In the Create Retention Policy dialog box, set the parameters in the Cleanup Scope step and click Next.
    Parameter Description
    Cleanup Scope The retention policy can be applied to a namespace or an image repository.
    • Namespace: The retention policy is applied to all image repositories in the specified namespace.
    • Repository: If you specify both a namespace and an image repository, the retention policy is applied to the specified image repository in the namespace.
      Note If you specify only the namespace, the retention policy is applied to all image repositories in the namespace.
    Trigger Type The execution method.
    • Automatic: Container Registry automatically runs image cleanup tasks every week or every month to delete image versions.
    • Manual: You must manually run image cleanup tasks. For more information, see Manually trigger image cleanup tasks.
    Trigger Type The recurrence of the image cleanup tasks that Container Registry automatically runs. Valid values: Every Week and Every Month.
    Note This parameter is required only when you set the Trigger Type parameter to Automatic.
  8. In the Retention Policy step, set the parameters and click Create Retention Policy.
    Parameter Description
    Keep recently pushed images Required. The number of recently pushed images that you want to retain.
    Keep image tags like Optional. In addition to the number of recently pushed images that you want to retain, you can specify the image versions that you want to retain.
    Note Default value: .*. It indicates that all image versions are retained in addition to the specified number of 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. In the left-side navigation pane, click Instances.
  4. On the Instances page, click the required Container Registry Enterprise Edition instance.
  5. On the management page of the Container Registry Enterprise Edition instance, choose Repositories > Version Management in the left-side navigation pane.
  6. On the Version Management page, find the retention policy that you want to apply and click Execute in the Actions column.
  7. In the Tips message, click OK.

What to do next

After you delete image versions from an Container Registry Enterprise Edition instance, the image versions 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 versions, run artifact cleanup tasks. For more information, see Release the storage space of OSS.