Container Registry allows you to configure a repository to be immutable to prevent
image tags from being overwritten by incorrect operations. After you configure a repository
to be immutable, the existing and newly added image tags in the repository cannot
be overwritten except for the tag of latest. After you push an image with a tag other
than latest to the repository, you cannot push another image with the same tag to
the repository. This ensures consistency of your image tags. This topic describes
how to configure a repository to be immutable.
Procedure
- Log on to the Container Registry console.
- In the top navigation bar, select a region.
- In the left-side navigation pane, choose .
- On the Instance page, click the name of the Container Registry Enterprise Edition instance or click
Manage in the Actions column for the instance.
- In the left-side navigation pane on the management page of the instance, choose .
- On the Repositories page, find the repository that you want to configure and click
Manage in the Actions column.
- On the Details page, click Modify Settings in the upper-right corner.
- In the Modify Settings dialog box, select Immutable and click OK.
Note To configure a repository to be mutable, clear Immutable.
Configuration verification
- Run the
docker push
command to push a new image whose tag is not latest to the repository you configured.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 fails. 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 push
command to push a new image whose tag is latest to the repository you configured.docker push example-registry-vpc.cn-hangzhou.cr.aliyuncs.com/test/example:latest
- Push another image whose tag is the same as the tag of the image you pushed in Step
3.
The push request is successful. The image you pushed in Step
3 is overwritten by the image you pushed in this step.
- Configure the repository to be mutable.
- Push another image whose tag is the same as the tag of the image you pushed in Step
1.
The push request is successful. The image you pushed in Step
1 is overwritten by the image you pushed in this step.