- Newest
- Most votes
- Most comments
The solution was to update the command to authenticate the docker client with sudo.
Before I used:
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.<region>.amazonaws.com
After I used sudo:
aws ecr get-login-password --region <region> | sudo docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.<region>.amazonaws.com
After this, I was able to pull the docker image from ecr.
Hello there,
Take a glance at the logs cat ~/.ecr/log/ecr-login.log to get more insight into what's going on.
You can refer to this documentations:
no basic auth credentials from the docker push or docker pull commands - https://docs.aws.amazon.com/AmazonECR/latest/userguide/common-errors-docker.html#error-403
Thank you for your reply. There is no
.ecrfolder present inside the EC2 instance.If your EC2 instance is configured to use the Amazon ECR credential helper, only then you will be able to see logs from the Amazon ECR Docker Credential Helper stored in
~/.ecr/logRunning
docker loginshould return the message "Login Succeeded".The EC2 instance profile role with added policy
AmazonEC2ContainerRegistryReadOnlygives the EC2 instance the ability to list repositories and images within the repositories. It also includes the ability to pull images from Amazon ECR with the Docker CLI.Some recommendations:
-
Just to be sure you are not previously logged in and using stale credentials, you can log your Docker CLI out.
docker logout <aws-account-id>.dkr.ecr.<region>.amazonaws.com -
Be sure to ensure that Amazon ECR can authenticate and authorize your Docker push and pull requests from that EC2 instance. See options here: https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html
-
Hi,
Look on this page for all details: https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policy-examples.html
This is a sample policy allowing to pull images that is provided. You want to check your current existing ECR-related policies to see if you grant same auths ecr:BatchGetImage and ecr:GetDownloadUrlForLayer
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPull",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::account-id:user/pull-user-1",
"arn:aws:iam::account-id:user/pull-user-2"
]
},
"Action": [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
},
{
"Sid": "AllowAll",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::account-id:user/admin-user"
},
"Action": [
"ecr:*"
]
}
]
}
Best,
Didier
Thank you for the reply. I've added a custom policy, in respond to your reply:
{ "Version": "2012-10-17", "Statement": [ { "Resource": "*", "Sid": "AllowPull", "Effect": "Allow", "Action": [ "ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer" ] }, { "Sid": "AllowAll", "Resource": "*", "Effect": "Allow", "Action": [ "ecr:*" ] } ] }AWS editor was complaining about Principal being unsupported, which is why I didn't used it. Is this policy correct?
Doing a docker pull still returns the same error message.
Relevant content
- asked a year ago

that was a lifesaver lol thank you