Container Registry allows you to configure a repository to be immutable to prevent image tags from being overwritten due to misoperations. 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 that the images in the repository are consistent with the images that have been deployed in containers. 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, click Instances.
  4. On the Instances page, click the required Container Registry Enterprise Edition instance.
  5. On the management page of the Container Registry Enterprise Edition instance, choose Repositories > Repositories in the left-side navigation pane.
  6. On the Repositories page, find the repository that you want to configure and click Manage in the Actions column.
  7. On the page that appears, click Edit in the Details section.
  8. In the Modify Settings dialog box, select Immutable and click Confirm.
    Note To configure a repository to be mutable, clear Immutable.

Verification

  1. Run the docker push command to push an image whose tag is not latest to the repository.
    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 an image whose tag is latest to the repository.
    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.