我无法将 Docker 图像推送到 AWS ecr

I cant push Docker image to AWS ecr

我正在尝试将 Docker 图像从构建到 AWS ECR 的 Docker 文件中推送,但是当 运行 此命令时:

$ aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 477629773586.dkr.ecr.eu-west-1.amazonaws.com 

出现错误:

An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam::477629773586:user/albertosanmartin is not authorized to perform: ecr:GetAuthorizationToken on resource: * Error: Cannot perform an interactive login from a non TTY device

我已经安装并配置了这些文件:

~/.aws/configure:

[default]
...
[mrthink]
region = eu-west-1
output = json

~/.aws/credentials

[default]
...
[mrthink]
aws_access_key_id = ****
aws_secret_access_key = ****

似乎是命令 api 获取其他用户“albertosanmartin”

有人可以帮助我吗? 提前致谢。

如果您在 ~/.aws/credentials 中的 mrthink 配置文件名称下配置了凭据,则需要将 --profile 参数传递给 aws cli

$ aws  --profile mrthink ecr get-login-password \
--region eu-west-1 |\
docker login --username AWS \
--password-stdin 477629773586.dkr.ecr.eu-west-1.amazonaws.com 

用户 arn:aws:iam::477629773586:user/albertosanmartin 无权访问 ECR

您可以通过 sts get-caller-identity 电话仔细检查您的凭据,如果它们是您想要使用的。