Configure a repository to be immutable

更新时间:
复制 MD 格式

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

  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, choose Repository > Repositories.

  6. On the Repositories page, find the target repository and click Manage in the Actions column.

  7. On the Details page, click Edit.

  8. In the Modify Settings dialog box, select Immutable and click Confirm.

    Note

    To disable image tag immutability, deselect Immutable.

Verification

  1. Run the docker push command to push a new image with a tag other than 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 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 a new image with the latest tag 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.