Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fargate Task in ECS is not able to pull image from ECR repository using ECR interface endpoints

I am facing issue with pulling docker image from ECR repository and getting error - CannotPullContainerError: Error response from daemon

In my VPC, i have a private subnet which doesnt have NAT gateway connected. Hence to access ECR, i have created the below ECR interface endpoints and s3 endpoint and associated the private subnet with them,

  1. com.amazonaws.region.ecr.api
  2. com.amazonaws.region.ecr.dkr
  3. com.amazonaws.region.s3

I also updated the repository policy to below,

{
"Version": "2008-10-17",
"Statement": [
    {
        "Sid": "AllowPushPull",
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::account-id:root"
        },
        "Action": [
            "ecr:GetDownloadUrlForLayer",
            "ecr:BatchGetImage",
            "ecr:BatchCheckLayerAvailability",
            "ecr:PutImage",
            "ecr:InitiateLayerUpload",
            "ecr:UploadLayerPart",
            "ecr:CompleteLayerUpload"
        ]
    }
]

}

I also updated the fargate task security group to allow 443 port from vpc range. But still, am facing the same issue and unable to pull image. Can you please help with the same?

like image 254
user2616467 Avatar asked Oct 27 '25 11:10

user2616467


1 Answers

I think if your VPC endpoint is correct, You might need to add the below permission with above permission.

"ecr:GetAuthorizationToken"

Thanks

Ashish Bhatia

like image 100
Ashish Bhatia Avatar answered Oct 29 '25 01:10

Ashish Bhatia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!