我正在尝试允许一个 AWS 账户(下面称为“第二个”)在另一个 AWS 账户(下面称为“第一个”)的 ECR 存储库中提取图像。
我正在关注这些文件:
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/RepositoryPolicyExamples.html(设置权限)
- https://aws.amazon.com/premiumsupport/knowledge-center/secondary-account-access-ecr/(获取令牌)
我已将以下权限添加到 ECR 存储库:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowCrossAccountPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<second>:root"
},
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
}
]
}
然后我运行这个命令:eval "$(aws ecr get-login --no-include-email --region us-east-1 --profile second --registry-ids <second> <first>)"
我得到了这个结果:
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /Users/libby/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /Users/libby/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
我将商店更改为config.json
临时只是为了确保我可以看到身份验证已按预期添加到文件中,它是:
{
"auths": {
"<second>.dkr.ecr.us-east-1.amazonaws.com": {
"auth": "<super long token>"
},
"<first>.dkr.ecr.us-east-1.amazonaws.com": {
"auth": "<super long token>"
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.09.0 (darwin)"
},
"stackOrchestrator": "swarm"
}
最后我运行:docker pull <first>.dkr.ecr.us-east-1.amazonaws.com/<repo>:<tag>
并得到这个结果:
Error response from daemon: pull access denied for <first>.dkr.ecr.us-east-1.amazonaws.com/<repo>, repository does not exist or may require 'docker login'
我已经三次检查了所有帐号是否正确,回购肯定在那里。如果我使用相同的get-login
命令登录,我可以拉它,但是--profile first
.
我不知道还能尝试什么才能拉出这张图片!
Principal
将ECR 权限更改为"AWS": "arn:aws:iam::<second>:user/<user>"
没有任何区别。