1

I am trying to push a local docker image into the ECS repository I created.

Following this link link

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

Errors:

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

I also referred to the stack overflow question on this Question. Here the accepted answer is to have awscli version two. I feel I have version 2 of cli

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

In the above command if I don't use --profile I get the error.

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

What is that I am missing here? Could any one please help me out with this?

sumanth shetty
  • 1,335
  • 1
  • 15
  • 36

2 Answers2

2

if you need to use aws named profile of your configuration, then you can use aws cli to list the profiles

aws configure list

when you located the profile, use it in conjunction with 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
Mr.
  • 8,000
  • 13
  • 54
  • 78
1

I can reproduce this and the problem seems to be the position of the flag --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.

Here --profile flag is being passed to docker command which is after the pipe(|) char, so it is failing.

    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
    ✔ ~

This works because if we supply the flag anywhere before the pipe char it will be passed to aws command.

EDIT

I didnt read through your stackoverflow attached post, I just saw the error message in your post and answered. Seems like it is well explained aws-ecr-saying-cannot-perform-an-interactive-login-from-a-non-tty-device-after as well.

samtoddler
  • 6,742
  • 2
  • 19
  • 18