DevOps

    Docker push to AWS ECR failing with 'no basic auth credentials'


    Introduction

    When trying to push Docker images to AWS Elastic Container Registry (ECR), but without correct authentication, you get the "no basic auth credentials" error. DevOps services with error means the Docker client isn't authenticated with AWS ECR.

    Why did this error occured?

    Typically this happens because the Docker Client is not communicating with aws ecr correctly, leading to an outdated authentication method (or), an expired session, or incorrect AWS credentials. When you attempt a Docker push to AWS ECR, it is made through basic authentication, so when you attempt to do this without proper authentication, AWS ECR denies the Docker push request and returns the error "no basic auth credentials".

    Solution

    However, get-login is deprecated as of July 2021. If you're using AWS CLI version 2, then use get-login-password instead of get-login:

     

    Authenticate Docker with AWS ECR for AWS CLI v1

    If you using AWS CLI version 1, use the below command to authenticate Docker client

     

    $(aws ecr get-login --region <your_region>)

     

    Authenticate Docker with AWS ECR for AWS CLI v2

    If you using AWS CLI version 2, use the below command to authenticate Docker client

     

    aws ecr get-login-password | docker login --username AWS --password-stdin <your_account_id>.dkr.ecr.<your_region>.amazonaws.com

     

    Push Your Docker Image

    Once authenticated, you're all set! Now you can push your Docker image

    docker push <your_account_id>.dkr.ecr.<your_region>.amazonaws.com/repository-name:tag

     

    Conclusion

    In case the “no basic auth credentials” error happens, it is important to authenticate Docker correctly with the correct AWS CLI version. DevOps Engineer set up a secure connection by following the new commands for CLI v1 or v2. But after you’ve been authenticated, you can push Docker images to AWS ECR without any issues.

     

    Ready to transform your business with our technology solutions?     Contact Us today to Leverage Our DevOps Expertise. 

    Share

    facebook
    LinkedIn
    Twitter
    Mail
    Devops

    Related Center Of Excellence