Tags of ECR images concatenate, if images are the same.

0

So, i found out, if i push the same image, but with the different tag names, to the same repository in the AWS ECR, tags concatenate. I dont think thats how it should work? is it a bug, or im not understanding something?

Thanks

已提问 1 年前2957 查看次数
2 回答
3
已接受的回答

This is actually the expected behavior in AWS ECR. When you push an image to a repository with a different tag name, the image will be stored as a new tag for the same image, rather than creating a new copy of the image. This means that the tags will essentially be pointing to the same image, and any changes made to one tag will be reflected in all the other tags as well.

This behavior can be useful in cases where you have multiple versions of the same image and you want to keep them organized under the same repository. However, if you want to create completely separate copies of the image with different tags, you'll need to use different repository names or use a separate registry altogether.

AWS_Guy
已回答 1 年前
专家
已审核 1 年前
1

Expanding on the answer by @AWS_Guy, it's up to you whether you have images for one package (multiple versions of it) per repository or have images for lots of packages (and their versions) in a repository. You just manage it appropriately with a tagging strategy, e.g tagging each image ServiceName_VersionNumber.

When you upload an image by default it's tagged "latest" (and the previous "latest" becomes untagged) but you can instead decide what tag(s) to apply - typically include a version number. Note that making use of the default "latest" behaviour therefore only makes sense with images for a single package (with multiple versions) in a repo.

It's common to want to do both:

  • tag your images with a version number, and
  • be able to always refer to "latest" rather than a specific version number from ECS etc.

A common solution is to push the built image twice - first with no tag (ends up tagged "latest") and then with the version tag. ECR is smart enough to recognise that the image digest did not change and it will not try to actually upload the image twice. On the second push only the tag will be send to ECR. This is the behaviour you've seen.

专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则