Day 49: AWS ECR (Elastic Container Registry)

Day 49: AWS ECR (Elastic Container Registry)

#90daysofedvops

🚀 Introduction

🔸What is Amazon ECR?

Amazon ECR is a fully managed, private Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images. It integrates seamlessly with Amazon Elastic Container Service (Amazon ECS) and Amazon Elastic Kubernetes Service (Amazon EKS).

Amazon ECR (Elastic Container Registry) is a fully managed container image registry provided by AWS. It is used to securely store, share, and manage container images.


🔸Key Features of ECR:

  1. Image Storage: It stores container images, similar to a "cloud gallery" for your app images.

  2. Security: Images are encrypted and can be accessed securely.

  3. Integration: Works seamlessly with Amazon ECS, EKS, and AWS Fargate for deploying containers.

  4. Version Control: Tracks different versions of your container images.

Example:

If you build a Docker image for your app, you can push it to Amazon ECR. Later, you can pull this image from ECR to deploy it in services like ECS or EKS.


🔸Must Have


  1. Creating an ECR Repository

Assuming you’ve already got an AWS account and permissions correctly configured, the easiest way to get started is to create a new ECR repository via the Amazon Web Services UI.

Go to the ECR homepage and click the Get Started button.

This takes you to the Create repository page, enter the specifications for your ECR repo.


  1. First understand what is difference between mutable and immutable.

    In Amazon Elastic Container Registry (ECR), mutable and immutable refer to the tag mutability settings for container images:

    1. Mutable:

      • Allows you to overwrite an image tag with a new image.

      • For example, if you push a new image with the tag latest, it replaces the existing image with the same tag.

      • Use Case: Useful during development or when you frequently update images with the same tag.

    2. Immutable:

      • Prevents overwriting an image tag once it's pushed.

      • For example, if you push an image with the tag v1.0 and later attempt to push a new image with the same tag, ECR will block the operation.

      • Use Case: Ensures stability and avoids accidental overwrites in production environments.

How to Configure:

You can set the tag mutability setting when creating a repository in ECR or update it later through the AWS Management Console, CLI, or SDK.

Example:

  • Mutable: example-repo:latest can be updated.

  • Immutable: example-repo:v1.0 cannot be updated once pushed.

Select image tag mutability according to your need or requirement.

  1. After that open repo that you have created.

  2. Click on View push commands. It will show some commands. Follow the pictures and instructions to understand it in better way.

  1. As mentioned above, install Docker & AWS CLI → (add permisson and policy for ECR if you are IAM user). Check out the pictures provided below and follow them.

  2. After clicking View push commands copy paste your first 2 command.

    • I forgot to install docker that’s why it is showing error.

  • Also create File for docker as shown in below picture (under ls).

Paste remaining 3rd & 4th command as shown in below picture. As shown in picture, docker image is push successfully in repo.


🚀 Conclusion

In this tutorial, we learned the basics of containers and container registries, and we have seen how to set up and use ECR to store your images, and how to retrieve our stored images.

ECR is a useful tool, especially if you or your organization makes use of AWS as your Cloud solution. It gives you the advantage of working well with other Amazon services like IAM for security and ECS or EKS for deployments.


Thanks for reading to the end; I hope you gained some knowledge.❤️🙌

Linkedln

Twitter

Github