An ECS task cannot pull its image from ECR in a private subnet: "CannotPullContainerError". Why?
IntermediateScenarioECS, EKS, Lambda and ECR
Answer
Situation read → No network path to ECR or missing execution role permission.
What I'd do →
- Add interface endpoints
ecr.api,ecr.dkrand an S3 gateway endpoint for layers - Or provide NAT
- Execution role needs
AmazonECSTaskExecutionRolePolicy - Check SG allows 443 to the endpoints
- Retry the service
Why → Layers are stored in S3, which most people forget when building endpoints.
Interview tip → S3 gateway endpoint is part of the set.
More on ECS, EKS, Lambda and ECR
ECS on Fargate or on EC2: how do you choose?BeginnerDeploy a containerized API on ECS behind an ALB. What are the building blocks?BeginnerAn ECS service deployment is stuck, tasks start and stop repeatedly. How do you debug?IntermediateRoll out a new ECS service version with canary and automatic rollback.IntermediateEKS pods need access to S3 without node-level permissions. How?IntermediateUpgrade an EKS cluster from 1.31 to 1.33 safely.Intermediate