Delete image tags

Updated at:

Accumulated image tags from repeated builds consume Object Storage Service (OSS) storage and incur costs. Container Registry (ACR) Enterprise Edition instances support tag retention policies for bulk deletion of image tags.

Configure a tag retention policy

Image tags that fall outside the retention 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 Enterprise Edition instance that you want to manage.

  5. In the left-side navigation pane, choose Repository > Tags.

  6. On the Tags page, click Create Retention Policy.

  7. In the Create Retention Policy dialog box, configure the parameters in the Cleanup Scope step and click Next.

    Parameter

    Description

    Cleanup Scope

    Clean up image tags by Instance, Namespace, or Repository.

    • Instance: Cleans up all repositories in the instance. Each repository retains only the tags specified by the retention rules.

    • Namespace: Cleans up all repositories in the namespace. Each repository retains only the tags specified by the retention rules.

    • Repository: Cleans up a specific repository within a namespace.

      Note

      If you select Repository and then select only a namespace without specifying a repository, all repositories in that namespace are cleaned up.

    Trigger Type

    How tag deletion tasks run.

    Trigger Cycle

    Schedule for automatic execution: Every Week or Every Month.

    Note

    This parameter is required only when Trigger Type is set to Automatic.

  8. In the Retention Policy step, configure the parameters and click Create Retention Policy.

    Parameter

    Description

    Keep recently pushed images

    Required. Specify the number of recently pushed images to retain. Older images beyond this count are deleted.

    Keep image tags

    Optional. Use a regular expression to retain additional tags matching specific naming patterns, regardless of the recently pushed count. Defaults to .* (retain all tags). Examples:

    • release-v.*: Retains all tags starting with release-v (suitable for release versions).

    • stable-.*: Retains all tags starting with stable- (suitable for long-term stable versions).

Manually trigger tag deletion 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 Enterprise Edition instance that you want to manage.

  5. In the left-side navigation pane, choose Repository > Tags.

  6. On the Tags page, find the target tag retention policy and click Execute in the Actions column.

  7. In the Tips dialog box, click Confirm.

What to do next

Deleted image tags still occupy OSS storage. To free this space, run a garbage collection task. For more information, see Clean up OSS bucket storage.

FAQ

How do I clean up image tags from an ACR Personal Edition instance?

ACR Enterprise Edition and Personal Edition handle image tag cleanup differently:

  • Enterprise Edition: Supports tag retention policies for automatic cleanup. For details, see Configure a tag retention policy above.

  • Personal Edition: Does not support tag retention policies. Log on to the ACR console and manually delete unwanted image tags from the image repository page.