question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to login to ECR

See original GitHub issue

Hello. I am having issues logging in to ecr using docker-py, my code is as follows:

from docker import Client
client = Client(base_url = 'tcp://127.0.0.1:2375')
client.login(username='AWS', password=auth_code, registry='https://xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com')
client.pull('xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/foo:latest')

Results with the following error:

docker.errors.APIError: 500 Server Error: Internal Server Error ("error parsing HTTP 403 response body: invalid character 'Y' looking for beginning of value: "Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one."")

The thing is, auth_code is generated from aws ecr get-login, which works perfectly. Can any one shed some light on this?

I did some debugging and in docker/api/image.py response is status_code 500 text:

error parsing HTTP 403 response body: invalid character 'Y' looking for beginning of value: "Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one."

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
lie-nielsencommented, Mar 6, 2018

I found it helpful to delete the Amazon login credentials from ~/.docker/config.json as well. The token is only good for 12 hours.

0reactions
jess-lawrence-axomiccommented, Aug 25, 2016

It looks like somewhere in the login process the local version is finding what it thinks is an auth and so the login uses the cached result. Adding reauth=True to the login call fixes it. Sorry for the rabbit hole Tomas.

  DEBUG:docker.auth.auth:Looking for auth entry for 'xxx.dkr.ecr.us-east-1.amazonaws.com'
  DEBUG:docker.auth.auth:Found u'https://xxx.dkr.ecr.us-east-1.amazonaws.com'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to login to AWS ECR Repository through docker login ...
You need to first request for the authorization token from ECR using AWS CLI and then extract the password from it and then,...
Read more >
Troubleshooting Amazon ECR error messages
This indicates that your user does not have permissions granted to use Amazon ECR, or that those permissions are not set up correctly....
Read more >
AWS ECR get-login-password not working
If the AWS ECR get-login-password not working, worry not. Our experts are offering troubleshooting tips to fix the issue. Click to read.
Read more >
ECR docker login issues with CLI v2 #4962 - GitHub
I'm unable to run "aws ecs update-service --force-new-deployment --cluster {{cluster-name}} --service {{service-name}}" command after upgrading ...
Read more >
Please help - Cannot login to ECR repository - CircleCI Discuss
config.yml version: 2.1 orbs: aws-ecr: circleci/aws-ecr@8.1.2 jobs: build: machine: image: ubuntu-2204:2022.04.2 steps: - checkout - run: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found