You are currently viewing How to create a private repository in Amazon Elastic Container Registry (ECR) using AWS CLI?

How to create a private repository in Amazon Elastic Container Registry (ECR) using AWS CLI?

How to create a private repository in Amazon Elastic Container Registry (ECR) using AWS CLI?

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

Today we will discuss how to create a private repository in AWS Elastic Container Registry (ECR) using AWS CLI. We will also discuss on how to push and pull a docker image from AWS ECR private repository using AWS CLI.

What is Elastic Container Registry (ECR)?

Amazon Elastic Container Registry (Amazon ECR) is an AWS managed container image registry service that is secure, scalable, and reliable. Amazon ECR supports private repositories with resource-based permissions using AWS IAM. This is so that specified users or Amazon EC2 instances can access your container repositories and images. You can use your preferred CLI to push, pull, and manage Docker images, Open Container Initiative (OCI) images, and OCI compatible artifacts.

Components of AWS ECR:

Registry:

An Amazon ECR private registry is provided to each AWS account; you can create one or more repositories in your registry and store images in them.

Authorization token:

Your client must authenticate to Amazon ECR registries as an AWS user before it can push and pull images.

Repository:

An Amazon ECR repository contains your Docker images, Open Container Initiative (OCI) images, and OCI compatible artifacts.

Repository policy:

You can control access to your repositories and the images within them with repository policies.

Image:

You can push and pull container images to your repositories. You can use these images locally on your development system, or you can use them in Amazon ECS task definitions and Amazon EKS pod specifications.

Enough of theory, let us create a new repository in AWS ECR using CLI.

How to create a private repository in Amazon Elastic Container Registry (ECR) using AWS CLI?

Prerequisites:

AWS CLI installed and configured with proper access.

You can use below link to install and configure AWS CLI.

https://cloudaffaire.com/how-to-install-aws-cli/

https://cloudaffaire.com/how-to-configure-aws-cli/

https://cloudaffaire.com/how-to-install-docker-in-aws-ec2-instance/

Create a private repository in AWS ECR? using AWS CLI

You can view your AWS ECR private repository in AWS console, under ECR service.

How to create a private repository in Amazon Elastic Container Registry (ECR) using AWS CLI?

Get ECR repository details using AWS CLI

Create a docker image that we will push to our private ECR repository

Push or pull a docker image to AWS ECR private repository

You can view all the images in AWS ECR console.

How to create a private repository in Amazon Elastic Container Registry (ECR) using AWS CLI?

Get details on the images in your ECR container registry

Delete the ECR private repository and all the images

Hope you have enjoyed this article, to get more details on AWS ECR, please follow below link.

https://docs.aws.amazon.com/ecr/index.html

Leave a Reply