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

  1. Log on to the Container Registry console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, choose Enterprise Instances > Instances.
  4. On the Instance page, click the name of the Container Registry Enterprise Edition instance or click Manage in the Actions column for the instance.
  5. In the left-side navigation pane on the management page of the instance, choose Repositories > Repositories.
  6. On the Repositories page, find the repository that you want to configure and click Manage in the Actions column.
  7. On the Details page, click Modify Settings in the upper-right corner.
  8. In the Modify Settings dialog box, select Immutable and click OK.
    Note To configure a repository to be mutable, clear Immutable.

Configuration verification

  1. 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
  2. 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.
  3. 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
  4. 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.
  5. Configure the repository to be mutable.
  6. 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.