Can't push image to Amazon ECR - fails with “no basic auth credentials”

后端 未结 30 1863
旧巷少年郎
旧巷少年郎 2020-12-02 05:07

I\'m trying to push a docker image to an Amazon ECR registry. I\'m using docker client Docker version 1.9.1, build a34a1d5. I use aws ecr get-login --regi

相关标签:
30条回答
  • 2020-12-02 05:51

    This error generally gets thrown if ecr login has failed. I am using windows system and I used "Powershell" in Administrator mode to login to ecr first.

    Invoke-Expression $(aws ecr get-login --no-include-email)
    

    This should output "Login succeeded".

    0 讨论(0)
  • 2020-12-02 05:51

    I ran into this issue as well running on OSX. I saw Oliver Salzburg's response and checked my ~/.docker/config.json. It had multiple authorization credentials inside it from the different AWS accounts I have. I deleted the file and after running get-login again it worked.

    0 讨论(0)
  • 2020-12-02 05:54

    Update

    Since AWS CLI version 2 - aws ecr get-login is deprecated and the correct method is aws ecr get-login-password.

    Therefore the correct and updated answer is the following: docker login -u AWS -p $(aws ecr get-login-password --region us-east-1) xxxxxxxx.dkr.ecr.us-east-1.amazonaws.com

    0 讨论(0)
  • 2020-12-02 05:54

    If you use multiple profiles and you need to login to a profile that is not your default one, you need to login with this command:

    $(AWS_PROFILE=<YOUR PROFILE> aws ecr get-login --no-include-email --region eu-west-1)
    
    0 讨论(0)
  • 2020-12-02 05:54

    There is a very simple way to push docker images to ECR: Amazon ECR Docker Credential Helper. Just install it according to the provided guide, update your ~/.docker/config.json as the following:

    {
        "credsStore": "ecr-login"
    }
    

    and you will be able to push/pull your images without docker login.

    0 讨论(0)
  • 2020-12-02 05:56

    Following command works for me:

    sudo $(aws ecr get-login --region us-east-1 --no-include-email)
    

    And Then I run these commands:

    sudo docker tag e9ae3c220b23(image_id) aws_account_id.dkr.ecr.region.amazonaws.com/my-web-app
    
    sudo docker push aws_account_id.dkr.ecr.region.amazonaws.com/my-web-app
    
    0 讨论(0)
提交回复
热议问题