Advertisement
Beginner AWS, Elastic Container Registry (ECR)

How do you authenticate Docker to push and pull images from a private ECR repository?

Short answer

You authenticate Docker to ECR using the AWS CLI's ecr get-login-password command, which retrieves a temporary authentication token that is then piped directly into a docker login command, granting Docker time limited access to push and pull images from your private ECR…

Save AWS mock interview
Advertisement
AModel answer
You authenticate Docker to ECR using the AWS CLI's ecr get-login-password command, which retrieves a temporary authentication token that is then piped directly into a docker login command, granting Docker time limited access to push and pull images from your private ECR repository, relying on your existing IAM credentials rather than requiring a separate, permanently stored registry password.
Example

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com

Real-world example
A CI/CD pipeline automatically authenticates to ECR using temporary credentials derived from its assumed IAM role, pushing a newly built container image without ever needing a separately managed, long lived registry password stored anywhere in the pipeline configuration.
Likely follow-ups
  • How long does an ECR authentication token remain valid before needing to be refreshed?
  • What IAM permissions are required to push and pull images from ECR?
Related topics