Clean up image tags
After an image is built multiple times, old versions continue to occupy Object Storage Service (OSS) storage space and incur additional fees. Container Registry (ACR) Enterprise Edition lets you use a tag retention policy to clean up unneeded image tags in batches.
Configure a tag retention policy
After you configure a retention policy for image tags, the image tags that fall outside the policy are cleaned up.
Cleaned-up image tags cannot be restored. You must push the images again to recreate them. If Trigger Type is set to Automatic, the task deletes image tags on the weekly or monthly schedule, and an overly broad scope may delete image tags that running workloads still reference.
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 Enterprise Edition instance management page, choose .
On the Tags page, click Create Retention Policy.
In the Create Retention Policy dialog box, in the Cleanup Scope configuration wizard, configure the parameters, and then click Next.
Parameter
Description
Cleanup Scope
Clean up image tags by Instance, Namespace, or Repository.
Instance: The cleanup scope is all repositories in the instance. Each repository retains the specified image tags.
Namespace: The cleanup scope is all repositories in the namespace. Each repository retains the specified image tags.
Repository: The cleanup scope is the specified repository. Select both a namespace and a repository.
NoteIf you select Repository and specify only a namespace without selecting a specific repository, the cleanup scope is all repositories in that namespace.
Trigger Type
Automatic: The tag cleanup task runs on a weekly or monthly schedule to clean up image tags.
Manual: The cleanup task runs only when you start it. For instructions, see Manually trigger the tag cleanup task.
Trigger Cycle
Select the execution cycle for automatic execution. The tag cleanup task supports Every Week and Every Month.
NoteThis parameter is required only when Trigger Type is set to Automatic.
In the Retention Policy configuration wizard, configure the parameters, and then click Create Retention Policy.
Parameter
Description
Retain Recently Pushed Images (Required)
The number of most recently pushed images to retain. Older versions beyond this number are cleaned up.
Retain Image Tags (Optional)
Uses a regular expression to retain additional image tags that match a naming rule. These image tags are not subject to the preceding number limit. The default value is
.*, which indicates that all image tags are retained. Examples:release-v.*: Retains all image tags that start withrelease-v(applicable to official release versions).stable-.*: Retains all image tags that start withstable-(applicable to long-term stable versions).
Manually trigger the tag cleanup task
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 Enterprise Edition instance management page, choose .
On the Tags page, in the Actions column of the target retention policy, click Execute .
In the Tips dialog box, click Confirm.
What to do next
After you clean up the image tags of an Enterprise Edition instance, the OSS bucket storage space that the image tags occupy still exists. To release this storage space, run the artifact cleanup task. For instructions, see Clean up OSS bucket storage.
FAQ
How do I clean up image tags in an ACR Personal Edition instance?
ACR Enterprise Edition and Personal Edition handle image tag cleanup differently:
Enterprise Edition: Supports the tag retention policy for automatic cleanup of image tags. Configure a tag retention policy, and the system automatically cleans up the image tags that fall outside the policy scope at regular intervals.
Personal Edition: Does not support the tag retention policy and cannot clean up image tags automatically. Log on to the Container Registry console. On the image repository page of the Personal Edition instance, manually delete the image tags that you no longer need.
WarningDeleted image tags cannot be restored. You must push the images again to recreate them.