Notes to Self

Alex Sokolsky's Notes on Computers and Programming

AWS Elastic Container Registry (ECR) CLI

For all the commands below the region should be set via environment or via cli.

ECR Repo

aws ecr describe-repositories

To create an ecr repo:

aws ecr create-repository --repository-name _name_

Get login and password for using it in docker login:

aws ecr get-login-password

Authenticate your Docker client to the Amazon ECR registry

aws ecr | docker login -u AWS -p <password_from_above_command> _repo_host_/_repo_name_

docker tag:

docker tag 7a8ba25b2d86 _repo_host_/_repo_name_:_tag_

docker push:

docker push _repo_host_/_repo_name_:_tag_

From: https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html

Retag an image

From https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-retag.html

Get the image manifest:

MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageTag=latest --output text --query 'images[].imageManifest')

Use the --image-tag option to put the image manifest to Amazon ECR with a new tag:

aws ecr put-image --repository-name amazonlinux --image-tag 2017.03 --image-manifest "$MANIFEST"

Verify that your new image tag is attached to your image:

aws ecr describe-images --repository-name amazonlinux