amazon-web-servicesdockeramazon-ecramazon-ecr-public

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


I have an Amazon ECR Public repository which is created in the ap-southeast-2 region. I tried to log in to the ecr-public with the following command.

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

But I'm getting the following error,

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

Why I'm getting this error?


I've configured the AWS credentials via CLI and I could log in to the ecr private repositories in the same region using the following command.

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

Didn't get any errors.

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

I tried most of the solutions mentioned in the following articles but couldn't solve my problem.


Solution

  • The 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 or in other words, private repositories are region-specific, available only within your region.

    But if you are going to deal with the ecr-public service, you must work with the us-east-1 region. Yes, I told you earlier, the 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 getting started article,

    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
    

    I hope this will help you to solve your problem, just change your region to us-east-1.