Search code examples
amazon-web-servicesdockeramazon-ecr

docker login with aws ecr get-login-password 401 error


I seem to have access via the aws-cli to the ECR, but can't seem to login. Any ideas what else I could try?

Network connectivity test:

% curl -I https://$ACCOUNT_ID.dkr.ecr.eu-west-1.amazonaws.com/    
HTTP/1.1 401 Unauthorized
Docker-Distribution-Api-Version: registry/2.0
Sizes: 
Www-Authenticate: Basic realm="https://$ACCOUNT_ID.dkr.ecr.eu-west-1.amazonaws.com/",service="ecr.amazonaws.com"
Date: Wed, 05 Jun 2024 13:55:15 GMT
Content-Length: 15
Content-Type: text/plain; charset=utf-8

AWS auth test (the account has AdministratorAccess):

% aws ecr describe-repositories --repository-names demo-flask-backend
{
    "repositories": [
        {
            "repositoryArn": "arn:aws:ecr:eu-west-1:1234567890:repository/demo-flask-backend",
            "registryId": "1234567890",
            "repositoryName": "demo-flask-backend",
            "repositoryUri": "1234567890.dkr.ecr.eu-west-1.amazonaws.com/demo-flask-backend",
            "createdAt": "2024-06-05T15:25:15.234000+02:00",
            "imageTagMutability": "MUTABLE",
            "imageScanningConfiguration": {
                "scanOnPush": true
            },
            "encryptionConfiguration": {
                "encryptionType": "AES256"
            }
        }
    ]
}

Problem:

% aws ecr get-login-password | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.eu-west-1.amazonaws.com
Error saving credentials: error storing credentials - err: exit status 1, out: `status code not OK but 500: {"message":"getting credential helper update: status code not OK but 401: {\"detail\":\"Incorrect authentication credentials\"}\n\n"}
{"message":"getting credential helper update: status code not OK but 401: {\"detail\":\"Incorrect authentication credentials\"}\n\n"}
{"message":"getting credential helper update: status code not OK but 401: {\"detail\":\"Incorrect authentication credentials\"}\n\n"}`

Docker version:

% docker --version
Docker version 26.1.1, build 4cf5afa

Solution

  • I don't understand why, but after I did a regular successful docker login by typing in my credentials for hub.docker.com and then doing the login above, it worked..