Delete image tags
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.
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, choose .
On the Tags page, click Create Retention Policy.
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.
NoteIf 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.
Automatic: Runs tag deletion tasks weekly or monthly.
Manual: Trigger deletion on demand. For more information, see Manually trigger tag deletion tasks.
Trigger Cycle
Schedule for automatic execution: Every Week or Every Month.
NoteThis parameter is required only when Trigger Type is set to Automatic.
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 withrelease-v(suitable for release versions).stable-.*: Retains all tags starting withstable-(suitable for long-term stable versions).
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, choose .
On the Tags page, find the target tag retention policy and click Execute in the Actions column.
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.