Pages

Wednesday, February 5, 2020

Playing With Container Registry in Aws - ECR

Share it Please
While working with containers, it is always necessary to have a place where we can store our application images. Docker provides a Container registry, DockerHub to store images. Similarly Amazon also provides a Service called ECR, “elastic container registry” for storing Images. In this article we can see the basics of using ECR in Aws


ECR  is a managed registry service for Aws. This Registry is used to store, manage and deploy docker container images. Ecr is integrated with the Amazon Container Service ( ECS ).


Using Ecr is quite easy. All we have to do is to create it and use it. There will be no upfront fee for using the Ecr. We only need to pay for the amount of data we store in the repositories and data transferred to the internet. 

1. create a ECR registry as below,


On the same screen, we can see two options
Tag immutability : this feature prevents image tags from being over written by subsequent images using the same tag


Scan on Push : by enabling this feature we enable scanning the image automatically whenever it is pushed to the repository.


We can see that repository is created as below,


2. Ensure Aws cli is installed and configured correctly.Check how to configure and install aws cli from here. Once configured, run the aws cli command to find the configured ecr repositories as below,
List the existing image repositories using aws cli as below,
jagadishm@[/Volumes/Work]: aws ecr describe-repositories
{
"repositories": [
     {
         "repositoryArn": "arn:aws:ecr:us-east-2:761772797825:repository/container-repo-testing",
         "registryId": "761772797825",
         "repositoryName": "container-repo-testing",
         "repositoryUri": "761772797825.dkr.ecr.us-east-2.amazonaws.com/container-repo-testing",
         "createdAt": 1580113624.0
     }
]
}

3. Once the repo is created, click on the Ecr respository and check the Push Commands.
4. Retrieve the login command to use to authenticate your Docker client to your registry.

jagadishm@[/Volumes/Work]: $(aws ecr get-login --no-include-email --region us-east-2)
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded

5. Downlaod a Docker image from Docker hub or create your own. Oncethe image is available, tag it as below


jagadishm@[/Volumes/Work]: docker pull docker.io/jagadesh1982/testing-service:1


6. Push the image to the Ecr registry as below,
The rest of the docker commands work in the same way.

No comments :

Post a Comment