36

Trying to familiarize myself with ECR - i understand that you should be able to push as many repositories as you like to Docker registry.

However, ECR has a concept of a 'repository'. So if i have 10 different containers comprising my app, does it mean i need 10 repositories in a registry?

Can i have one repository and push 10 different containers with their 'latest' tags?

Currently if i tag another image with the same {registry}/{repository_name} pattern, it replaces latest tag on my other image:

ECR overview

zaitsman
  • 8,984
  • 6
  • 47
  • 79

1 Answers1

44

If you want to get the detailed descriptions, I would check out the What Is Amazon EC2 Container Registry? page, which describes the components in detail, but the high level difference between the two is this: Each account has a Registry, each Registry can contain several repositories. Each Repository can contain several Images. An image can have Several Tags, a Tag can only exist once per Repository.

If you look at the reference to a repository:

[account].dkr.ecr.[region].amazonaws.com/[repository_name]

The part in front of the first / is your registry, the part after the first / is your repository.

So what you're experiencing here is that by pushing a second image to the same repository, you're changing the reference that the latest tag is pointing to.

If you want to have multiple distinct images, each with their own latest tag, each one should have it's own Repository. Based on the Pricing for ECR, you only pay based on the storage size and transfer from an ECR Repo, so there's little benefit to not creating additional repos.

Jamie Starke
  • 8,776
  • 3
  • 38
  • 58
  • 9
    the issue, however, is that i need to have a different IAM principal with 'create repository' permissions if i want to push new images from CI; or pre-create all repositories. If i could push directly to a registry it would make a bit more sense. e.g. i don't see any value int he ECR repository concept. – zaitsman Sep 15 '17 at 22:53
  • Ah, that all sounds like useful information to have originally included in your question. That said, given that you are thinking of putting all of the images in a single repository anyway, I don't see the downside in allowing your CI to create new repositories. If I'm understanding your use case correctly, I don't know of any docker registries that would be well suited to your use case. – Jamie Starke Sep 16 '17 at 02:00
  • 1
    Automatic repository creation would solve this issue, which is highly requested but still just a proposal: https://github.com/aws/containers-roadmap/issues/853 and https://github.com/aws/containers-roadmap/issues/799 . – Adrian Baker Dec 16 '21 at 03:55