1
votes

I have wanted to push my docker image to AWS ECR. After log in into aws ecr using terminal, I have to tag my image for aws ECR. It seems it creates new image beside old image after tagging for aws ecr.

How can I tag my existing images for aws ECR without creating new images and push to aws ECR? Is there any way to define it in docker compose file?

1
what's command did you build and tag an image ? - Thanh Nguyen Van
This Command I executed:: docker tag app_app:latest 502341150717.dkr.ecr.us-east-2.amazonaws.com/app_app:latest. app_app is exsting image in my machine. I have build the image before creating aws ecr repository. - MD. Ashfaqur Rahman Tahashin

1 Answers

1
votes

In order to retag Docker Image pushed with tag "latest" originally then you need to put a new tag here .

Docker Command to rename a tag is :

docker tag <old_tag> <new_tag>

where <new_tag> should be

repository:tag

  • repository : "502341150717.dkr.ecr.us-east-2.amazonaws.com/app_app"
  • tag : "dev.latest" or "prod.latest" (or anything else except "latest")

Hence the command that should work will be :

docker tag app_app:latest 502341150717.dkr.ecr.us-east-2.amazonaws.com/dev.latest

FYI : "app_app" is the name of your ECR Repository where images are stored and it is not the name of your image as mentioned in the comment's. Your original image was tagged as 'latest' and your are renaming it to 'latest' again, hence it doesn't work for you.