Push Docker Image to Amazon ECR

Step: 1 Create Private repository in AWS.

Step 2: Login to your AWS account through command line.

Step 2A: If you are trying to login first time you need to configure the credential.


$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNNJHG7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDEjhgNG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

Step 2B: If you are handling multiple account, you should create profile first.

$ aws configure --profile userprodaccount
AWS Access Key ID [None]: AKIAIOSFODgfhNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEdfsMgfdhI/K7MdsfDENG/bPxRfiCYEdfXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

Step 2C: If you have already create an profile, then check your profile is available by using below command.

$ aws configure list-profiles

Step 2D: If you are going to use a profile then make sure your add –profile <profile name> as options and parameters section below.

$aws <command> <subcommand> [options and parameters]

Step 3: Push your Docker image to Amazon ERC.

Step 3A: Login into AWS command line.

$aws ecr get-login-password --region <region-name> --profile <profile name> | docker login --username AWS --password-stdin <repository URI>

Step 3B: Build your docker image and tag it with Amazon ECR

$docker tag <imagename:version> <repositoryURL>/my-repository-name:tag

Step 3C: Push your docker image to ECR.

$docker image push <IMAGE_NAME[:TAG]>

Subscribe to our newsletter to get the latest post in your inbox.

Leave a Reply

Your email address will not be published. Required fields are marked *