Amazon ECR
User Guide (API Version 2015-09-21)

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Retagging an Image with the AWS CLI

With Docker Image Manifest V2 Schema 2 images, you can use the --image-tag option of the put-image command to retag an existing image. You can retag without pulling or pushing the image with Docker. For larger images, this process saves a considerable amount of network bandwidth and time required to retag an image.


This procedure does not work for Windows clients because of the way the AWS CLI output text is interpreted by the shell. To retag an image on Windows clients, see Retagging an Image with the AWS Tools for Windows PowerShell.

To retag an image with the AWS CLI

  1. Use the batch-get-image command to get the image manifest for the image to retag and write it to an environment variable. In this example, the manifest for an image with the tag, latest, in the repository, amazonlinux, is written to the environment variable, MANIFEST.

    MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageTag=latest --query 'images[].imageManifest' --output text)
  2. Use the --image-tag option of the put-image command to put the image manifest to Amazon ECR with a new tag. In this example, the image is tagged as 2017.03.


    If the --image-tag option is not available in your version of the AWS CLI, upgrade to the latest version. For more information, see Installing the AWS Command Line Interface in the AWS Command Line Interface User Guide.

    aws ecr put-image --repository-name amazonlinux --image-tag 2017.03 --image-manifest "$MANIFEST"
  3. Verify that your new image tag is attached to your image. In the output below, the image has the tags latest and 2017.03.

    aws ecr describe-images --repository-name amazonlinux


        "imageDetails": [
                "imageSizeInBytes": 98755613,
                "imageDigest": "sha256:8d00af8f076eb15a33019c2a3e7f1f655375681c4e5be157a2685dfe6f247227",
                "imageTags": [
                "registryId": "aws_account_id",
                "repositoryName": "amazonlinux",
                "imagePushedAt": 1499287667.0