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

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

How to create a public 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 public 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 public repository using AWS CLI.

What is Elastic Container Public Registry (ECR)?

Amazon Elastic Container Public Registry is a managed AWS container image registry service that is secure, scalable, and reliable. Amazon ECR supports public image repositories with resource-based permissions using AWS IAM so that specific users can access your public repositories to push images. Developers can use their preferred CLI to push and manage Docker images, Open Container Initiative (OCI) images, and OCI compatible artifacts. Your images are publicly available to pull, either anonymously or using an Amazon ECR Public authentication token.

Components of AWS ECR Public Registry:

Amazon ECR Public Gallery:

The Amazon ECR Public Gallery is the public portal that lists all public repositories hosted on Amazon ECR Public. Visit the Amazon ECR Public Gallery at https://gallery.ecr.aws.com

Registry:

A public registry is provided to each AWS account; you can create public image repositories in your public registry and store images in them.

Authorization token:

Your client must authenticate to a public registry as an AWS user before it can push images to a public repository. For image pulls, Amazon ECR Public accepts both anonymous pulls and pulls using an authentication token.

Repository:

An Amazon ECR image 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 public repository in AWS ECR using CLI.

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

Prerequisites:

AWS CLI and Docker installed and configured.

Step 1: Get details on your AWS ECR public registry using AWS CLI.

Note: When you create a new AWS account, AWS automatically assigns a public registry in “us-east-1” region of your ECR service.

Step 2: Set a display name for your ECR public registry.

Note: This display name will be visible to the public in AWS public image gallery

Step 3: Create a new public repository in AWS ECR using AWS CLI.

You can also create a new public ECR repository from AWS management console.

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

Step 4: Get details on AWS ECR public repository using AWS CLI.

Next, we will create a docker image in our local system and authenticate, tag and push the docker image to AWS ECR public repository.

Step 5: Create a new docker image and push the image to AWS ECR public repository.

Step 6: Get details on the public image in your ECR repository.

You can also view your public images in AWS public image gallery.

Step 7: Clean up.

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