Amazon Elastic Container Registry
Amazon Elastic Container Registry is used to store docker images in Amazon AWS cloud.
To create a repository using awscli command line tool, run
aws ecr create-repository --repository-name sok-repository --region ap-southeast-1
In Amazon AWS console, you can see the newly created repository by going to “Elastic Container Registry” page in the region where you created the repository.
https://ap-southeast-1.console.aws.amazon.com/ecr/repositories?region=ap-southeast-1
To see the details from command line, run
aws ecr describe-repositories --region ap-southeast-1
From the command, you will see repositoryUri, this is used to push your docker images.
I have following docker images
[root@instance-20210426-0136 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE sevrerok/okapache 1.2 c3832b03b548 2 hours ago 214MB sevrerok/okapache 1.1 d1a86f0eb69a 2 hours ago 214MB ubuntu 20.04 7e0aa2d69a15 2 days ago 72.7MB sevrerok/okapache 1.0 7e0aa2d69a15 2 days ago 72.7MB [root@instance-20210426-0136 ~]#
I need to push the image sevrerok/okapache:1.2 to Amazon ECR, for this first tag the docker image with repository name.
docker tag sevrerok/okapache:1.2 497940214440.dkr.ecr.ap-southeast-1.amazonaws.com/sok-repository
Now docker images will show
[root@instance-20210426-0136 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE sevrerok/okapache 1.2 c3832b03b548 2 hours ago 214MB 497940214440.dkr.ecr.ap-southeast-1.amazonaws.com/sok-repository latest c3832b03b548 2 hours ago 214MB sevrerok/okapache 1.1 d1a86f0eb69a 2 hours ago 214MB ubuntu 20.04 7e0aa2d69a15 2 days ago 72.7MB sevrerok/okapache 1.0 7e0aa2d69a15 2 days ago 72.7MB [root@instance-20210426-0136 ~]#
Login to ECR
aws ecr get-login
It will display command you need to login to ECR using docker. Run the command to login to ECR.
To push the docker image to ECR, run
docker push 497940214440.dkr.ecr.ap-southeast-1.amazonaws.com/sok-repository
Now the image is pushed to ECR, you will be able to see it using AWS console or awscli
[root@instance-20210426-0136 ~]# aws ecr list-images --repository-name sok-repository { "imageIds": [ { "imageTag": "latest", "imageDigest": "sha256:3cb5b8ef33bf913018f28dc3adf93b96c66667b517fe800a99bd0defd9dc6130" } ] } [root@instance-20210426-0136 ~]#
To delete the ECR repo, use following command
aws ecr delete-repository --repository-name sok-repository --region ap-southeast-1 --force
See AWS