简体   繁体   English

使用命名空间在 AWS ECR 中存储图像

[英]Storing images in AWS ECR using namespaces

AWS claims to support namespacing rules on repos but I don't follow how you're supposed to set them up. AWS 声称支持 repos 上的命名空间规则,但我不遵循您应该如何设置它们。 According to the docs here :根据这里的文档:

Repository names can support namespaces, which you can use to group similar repositories.存储库名称可以支持命名空间,您可以使用命名空间对相似的存储库进行分组。 For example if there are several teams using the same registry, Team A could use the team-a namespace while Team B uses the team-b namespace.例如,如果有多个团队使用相同的注册表,则团队 A 可以使用 team-a 命名空间,而团队 B 使用 team-b 命名空间。 Each team could have their own image called web-app, but because they are each prefaced with the team namespace, the two images can be used simultaneously without interference.每个团队都可以拥有自己的名为 web-app 的图像,但由于它们都以团队命名空间为前缀,因此可以同时使用两个图像而不会相互干扰。 Team A's image would be called team-a/web-app, while Team B's image would be called team-b/web-app.团队 A 的图像将称为 team-a/web-app,而团队 B 的图像将称为 team-b/web-app。

So we created a repo in our registry at <registry ID>.dkr.ecr.<region>.amazonaws.com/mycompany/myproj因此,我们在注册表中创建了一个位于<registry ID>.dkr.ecr.<region>.amazonaws.com/mycompany/myproj

Based on this, I would then expect to be able to store multiple images in this myproj namespace such as:基于此,我希望能够在这个myproj命名空间中存储多个图像,例如:

<registry ID>.dkr.ecr.<region>.amazonaws.com/mycompany/myproj/imageone:latest

<registry ID>.dkr.ecr.<region>.amazonaws.com/mycompany/myproj/imagetwo:latest

However, when I try to push one of these images, it tells me the repository mycompany/myproj/imageone does not exist.但是,当我尝试推送这些图像之一时,它告诉我存储库mycompany/myproj/imageone不存在。 I don't know why it's thinking that imageone is part of my repository name and not my image name:tag.我不知道为什么它认为imageone是我的存储库名称的一部分,而不是我的图像名称:tag。 Am I doing something wrong here with how my repository is named or how I'm naming/tagging my images?我在这里的存储库命名方式或我命名/标记图像的方式有问题吗?

ECR doesn't support "namespaces" as a hierarchical grouping concept. ECR 不支持“命名空间”作为分层分组概念。 While ECR has a flat structure, it's common to use slashes within repository names to organise repositories.虽然 ECR 具有扁平结构,但通常在存储库名称中使用斜杠来组织存储库。

In your example, you would create two repositories with names:在您的示例中,您将创建两个具有名称的存储库:

  1. mycompany/myproj/imageone
  2. mycompany/myproj/imagetwo

You could then use this naming convention to write identity-based policies, eg IAM group myproj could be granted permissions to resource arn:aws:ecr:us-east-1:123456789012:repository/mycompany/myproj/* .然后,您可以使用此命名约定来编写基于身份的策略,例如,可以向 IAM 组myproj授予对资源arn:aws:ecr:us-east-1:123456789012:repository/mycompany/myproj/* Other than that, there's nothing special about using the common prefix and ECR considers them two repositories that happen to be named similarly.除此之外,使用公共前缀并没有什么特别之处,ECR 将它们视为两个碰巧名称相似的存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM