All Products
Search
Document Center

Container Registry:Configure a repository to be immutable

Last Updated:Jan 30, 2024

Container Registry supports the image tag immutability feature based on repository configurations. After you configure a repository to be immutable, existing and new image tags except the latest tag cannot be overwritten. This feature ensures that images of the same tag can be pushed only once, the tag of an image remains consistent, and image tags are not overwritten due to accident operations.

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 Enterprise Edition instance that you want to manage.

  5. In the left-side navigation pane of the management page of the Container Registry Enterprise Edition instance, choose Repository > Repositories.

  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 disable the image tag immutability feature, clear Immutable.

Verification

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

  5. Clear the Immutable check box.

  6. 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.