Container Registry supports image tag immutability at the repository level. After you enable this feature, all existing and new image tags, except for the latest tag, cannot be overwritten. This ensures image tag consistency. This feature ensures an image with a specific tag can be pushed only once, preventing accidental overwrites.
Procedure
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 Repositories page, find the target repository and click Manage in the Actions column.
-
On the Details page, click Edit.
-
In the Modify Settings dialog box, select Immutable and click Confirm.
NoteTo disable image tag immutability, deselect Immutable.
Verification
-
Run the
docker pushcommand to push a new image with a tag other thanlatestto the repository.docker push example-registry-vpc.cn-hangzhou.cr.aliyuncs.com/test/example:v1 -
Push another image whose tag is the same as the tag of the image you pushed in Step 1.
The push request is denied. The following error is returned, which indicates that the image tag cannot be overwritten:
The requested tag already exists and cannot be overwritten. -
Run the
docker pushcommand to push a new image with thelatesttag to the repository.docker push example-registry-vpc.cn-hangzhou.cr.aliyuncs.com/test/example:latest Push another image whose tag is also latest. The tag is the same the tag of the image that you pushed in Step 3.
The push is successful. The image overwrites the image that you pushed in Step 3.
Clear the Immutable check box.
Push another image whose tag is the same as the tag of the image you pushed in Step 1.
The push is successful. The image overwrites the image that pushed in Step 1.