无法连接到端点 URL:"https://api.ecr-public.xxxxxxxxx.amazonaws.com/"

Could not connect to the endpoint URL: "https://api.ecr-public.xxxxxxxxx.amazonaws.com/"

我在 ap-southeast-2 区域创建了一个 Amazon ECR Public 存储库。我尝试使用以下命令登录 ecr-public

aws ecr-public get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin public.ecr.aws/<default_alias>

但是我收到以下错误,

Could not connect to the endpoint URL: "https://api.ecr-public.ap-southeast-2.amazonaws.com/"
Error: Cannot perform an interactive login from a non TTY device

为什么会出现此错误?


我已经通过 CLI 配置了 AWS 凭证,我可以使用以下命令登录同一区域的 ecr 私有存储库。

aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin <accound_id>.dkr.ecr.ap-southeast-2.amazonaws.com

没有发现任何错误。

WARNING! Your password will be stored unencrypted in /home/wasdkiller/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

我尝试了以下文章中提到的大部分解决方案,但无法解决我的问题。

Amazon ECR Public repositories are not region-specific, you could see the same Amazon ECR Public repositories in many other regions, but public repositories only you can see like this. The Amazon ECR 或换句话说,私有存储库 区域特定,仅在您所在的区域可用。

但是如果您要处理 ecr-public 服务,则必须使用 us-east-1 区域。是的,我之前告诉过你,Amazon ECR Public repositories are not region-specific. But the ecr-public command and their subcommands are region-specific. Here is what they mentioned in the Quick start: Publishing to Amazon ECR Public using the AWS CLI 入门文章,

Step 2: Authenticate to a public registry

After you have installed and configured the AWS CLI, authenticate the Docker CLI to your public registry. That way, the docker command can push to and pull images from an Amazon ECR public repository. The AWS CLI provides a get-login-password command to simplify the authentication process.

To authenticate Docker to an Amazon ECR public registry with get-login-password, run the aws ecr-public get-login-password --region us-east-1 command. The Amazon ECR Public registry requires authentication in the us-east-1 Region, so you need to specify --region us-east-1 each time you authenticate. The authentication token received gives you access to each public registry your IAM principal has access to. When passing the authentication token to the docker login command, use the value AWS for the username and specify public.ecr.aws, which is the common public registry URI.

aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws

我希望这能帮助您解决问题,只需将您的区域更改为 us-east-1.