最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Getting no basic auth credential from AWS ECR when pulling image - Stack Overflow

programmeradmin0浏览0评论

I am trying to pull image from AWS ECR. I am on an EC2 machine and as you can see that I can login successfully. However, when I am trying to pull the image using docker pull I am getting Head <> : no basic auth credential

export REGION='us-east-1'
my_account_id=$(aws sts get-caller-identity --query "Account" --output text)
aws ecr get-login-password --region $REGION| docker login --username AWS --password-stdin ${my_account_id}.dkr.ecr.${REGION}.amazonaws/my-base-image:latest
    
Login Succeeded

cat ~/.docker/config.json is showing the auth

However, I am unable to pull the image --

sudo docker pull 123456789012.dkr.ecr.us-east-1.amazonaws/my-base-image:latest

Error response from daemon: Head ";: no basic auth credential

I should be able to pull the image successfully

I am trying to pull image from AWS ECR. I am on an EC2 machine and as you can see that I can login successfully. However, when I am trying to pull the image using docker pull I am getting Head <> : no basic auth credential

export REGION='us-east-1'
my_account_id=$(aws sts get-caller-identity --query "Account" --output text)
aws ecr get-login-password --region $REGION| docker login --username AWS --password-stdin ${my_account_id}.dkr.ecr.${REGION}.amazonaws.com/my-base-image:latest
    
Login Succeeded

cat ~/.docker/config.json is showing the auth

However, I am unable to pull the image --

sudo docker pull 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-base-image:latest

Error response from daemon: Head "https://123456789012.dkr.ecr.us-east-1.amazonaws.com/v2/my-base-image/manifests/latest": no basic auth credential

I should be able to pull the image successfully

Share Improve this question asked Feb 5 at 14:20 JudiJudi 9124 gold badges15 silver badges32 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

You ran docker login with your regular EC2 user account. Then you are trying to run the docker pull with sudo, which runs as the root EC2 account. The root EC2 account isn't logged into ECR. You either need to run all docker commands with sudo or run none of them with sudo.

It looks like you're correctly logging into AWS ECR, but the issue probably stems from root vs. non-root user authentication in Docker. When you run sudo docker pull, it does not use the authentication stored in your user's ~/.docker/config.json because sudo runs as root, which has a separate home directory (/root/.docker/config.json).

发布评论

评论列表(0)

  1. 暂无评论