How to Re-tag an Image in AWS ECR

Are you managing Docker images in AWS ECR? Sometimes, you need to retag them to keep things organized. In this quick guide, we’ll show you how to retag your Docker images in AWS ECR Let’sy. Let’s get started!

Let’s consider an image named hello-world…


This content originally appeared on DEV Community and was authored by Amzar

Are you managing Docker images in AWS ECR? Sometimes, you need to retag them to keep things organized. In this quick guide, we'll show you how to retag your Docker images in AWS ECR Let'sy. Let’s get started!

Let's consider an image named hello-world-program with the following tags.

current tag new tag
[untagged] 0.0.2

Steps

  1. Setup AWS CLI
  2. Navigate to AWS ECR and choose the images you want to update. Copy the image digest (e.g., sha256:xxx), which is a unique and unchangeable identifier. Each image's content has its own distinct digest.
  3. Open terminal
  4. Run the following command to retrieve the image manifest and store it in the MANIFEST variable:

    MANIFEST=$(aws ecr batch-get-image --repository-name {REPO_NAME} --image-ids imageDigest={IMAGE_DIGEST} --output json | jq --raw-output --join-output '.images[0].imageManifest')
    
  5. Run the following command to update the image:

    aws ecr put-image --repository-name {REPO_NAME} --image-tag {NEW_TAG} --image-manifest "$MANIFEST"
    

Replace {REPO_NAME} with the name of your repository, {IMAGE_DIGEST} with the actual digest you copied from AWS ECR, and {NEW_TAG} with your desired tag

Refresh the page, and you’ll see that the existing [untagged] image is now updated to 0.0.2.

If you're on macOS and encounter the issue jq: command not found, check this guide for help.

Reference

  1. https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-retag.html
  2. https://stackoverflow.com/a/59675086


This content originally appeared on DEV Community and was authored by Amzar


Print Share Comment Cite Upload Translate Updates
APA

Amzar | Sciencx (2024-07-19T20:18:32+00:00) How to Re-tag an Image in AWS ECR. Retrieved from https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/

MLA
" » How to Re-tag an Image in AWS ECR." Amzar | Sciencx - Friday July 19, 2024, https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/
HARVARD
Amzar | Sciencx Friday July 19, 2024 » How to Re-tag an Image in AWS ECR., viewed ,<https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/>
VANCOUVER
Amzar | Sciencx - » How to Re-tag an Image in AWS ECR. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/
CHICAGO
" » How to Re-tag an Image in AWS ECR." Amzar | Sciencx - Accessed . https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/
IEEE
" » How to Re-tag an Image in AWS ECR." Amzar | Sciencx [Online]. Available: https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/. [Accessed: ]
rf:citation
» How to Re-tag an Image in AWS ECR | Amzar | Sciencx | https://www.scien.cx/2024/07/19/how-to-re-tag-an-image-in-aws-ecr/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.