Docker Community Forums

Share and learn in the Docker community.

Pull images from AWS ECR on AWS EC2 without using docker login but using EC2 Instance role and ECR repository permissions

docker
aws

(Pranshuverma) #1

Expected behavior

docker should pull image from AWS ECR on AWS EC2 instance with AWS EC2 role/policy and permission to all resources on aws ecr repository.

Actual behavior

Not able to pull image
getting is “unauthorized: authentication required”.

Additional Information

Steps to reproduce the behavior

  1. Assign AmazonEC2ContainerRegistryReadOnly policy to a role and the role to EC2 instance.
  2. Use below policy document to add permission to AWS ECR repository.

{
“Version”: “2008-10-17”,
“Statement”: [
{
“Sid”: “new policy”,
“Effect”: “Allow”,
“Principal”: “*”,
“Action”: [
“ecr:GetAuthorizationToken”,
“ecr:BatchCheckLayerAvailability”,
“ecr:GetDownloadUrlForLayer”,
“ecr:GetRepositoryPolicy”,
“ecr:DescribeRepositories”,
“ecr:ListImages”,
“ecr:BatchGetImage”
]
}
]
}

Let me know if this is possible.


(No3am) #2

I’m researching the same issue, did you get an answer for that? did you figure it out?