0

我正在尝试将本地 docker 映像推送到我创建的 ECS 存储库中。

按照此链接链接

aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin xxxxxxxxxxxx.dkr.ecr.region.amazonaws.com --profile loadeo

错误:

unknown flag: --profile
Unable to locate credentials. You can configure credentials by running "aws configure".

我还提到了这个Question的堆栈溢出问题。这里接受的答案是拥有 awscli 版本 2。我觉得我有 cli 的第 2 版

aws --version
aws-cli/2.0.19 Python/3.7.7 Windows/10 botocore/2.0.0dev23

在上面的命令中,如果我不使用 --profile 我会收到错误消息。

aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin xxxxxxxxxxxxxx.dkr.ecr.region.amazonaws.com



 Unable to locate credentials. You can configure credentials by running "aws configure".
Error: Cannot perform an interactive login from a non TTY device

我在这里想念什么?有人可以帮我解决这个问题吗?

4

2 回答 2

2

如果您需要使用配置的aws 命名配置文件,则可以使用aws cli 列出配置文件

aws configure list

当您找到配置文件时,将其与get-login-password结合使用

aws ecr get-login-password \
  --region <region> \
  --profile <profile> \
| docker login \
  --username AWS \
  --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com
于 2021-01-05T14:57:28.430 回答
0

我可以重现这个问题似乎是标志的位置--profile

        $ aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.eu-central-1.amazonaws.com --profile myprofile
    unknown flag: --profile
    An error occurred (UnrecognizedClientException) when calling the GetAuthorizationToken operation: The security token included in the request is invalid.

这里--profile标志被传递给在 pipe(|) 字符之后的docker命令,所以它失败了。

    15:51 $ aws --profile myprofile ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.eu-central-1.amazonaws.com
    Login Succeeded
    ✔ ~

这是有效的,因为如果我们在管道字符之前的任何位置提供标志,它将被传递给aws命令。

编辑

我没有阅读您的stackoverflow附加帖子,我只是在您的帖子中看到了错误消息并回答了。似乎也很好地解释了aws-ecr-saying-cannot-perform-an-interactive-login-from-a-non-tty-device-after

于 2021-01-05T14:53:26.853 回答