How to push a docker image to AWS ECR

  1. AWS account
  2. Access key id and secret access key
  3. Docker image
  1. Configure AWS CLI
  2. Create AWS repository/Set lifecyle policy
  3. Retrieve Password and authenticate to registry
  4. Set up IAM permissions to allow user access to registry
  5. Add tags to image
  6. Push image to Amazon Elastic Container Registry
  1. First we need to configure our AWS CLI. You will need to enter your Access Key ID and Secret Access Key for your user profile. As well as your default region. Leave the default output format blank as it will default to JSON.
aws configure
Output of the aws configure command
aws ecr create-repository --repository-name NAMEOFYOURREPO
aws ecr put -lifecycle-policy --registry-id YOURREGISTRYID --repository-name YOURREPONAME --lifecycle-policy-text '{"rules" [{"rulePriority":10,"description":"Expire old images","selection":{"tagStatus":"any","countType":"imageCountMoreThan","countNumber":800},"action":{"type":"expire"}}]}'
aws ecr get-login-password \
--region <region> \
| docker login \
--username AWS \
--password-stdin <aws_account_id>.dkr.ecr.<region>
aws iam attach-user-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess --user-name john_doe
docker tag YOURIMAGEID
docker push




AWS Solutions Architect Associate, AWS Certified Cloud Practitioner

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Lean That’s Better, Faster, Simpler

How to Setup Turbine Stream Dashboard

Task 3.3 — Hasura Auth API + Postman collection

Work with Version Control like a boss in 5min

Impersonating a Google cloud plattform Service account

Cloud Native and Chaos Engineering

The worst day ever for Smart Launcher

Anatomy of a Serverless YAML File

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin Crawford

Kevin Crawford

AWS Solutions Architect Associate, AWS Certified Cloud Practitioner

More from Medium

5 Steps to write unit testing in python using moto3 library

CloudZone wins Amazon Web Services 2021 Israel Partner Award

AWS EC2 Instance Lifecycle Overview

Setting up Multi-Node Apache Hadoop Cluster on AWS EC2 from scratch