AWS ECR setup
This post is a quick reference guide to setup aws
cli and pushing a docker image to ECR.
AWS Info
Keep following things handy while working with aws CLI commands
account_id
region=us-west-2
iam_user_access_key
iam_user_secret
Install aws cli
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html
verify that it works
aws --version
Configure AWS CLI
aws configure
# requires
iam_user_access_key
iam_user_secret
region=us-west-2
FORMAT=json
# verify
aws sts get-caller-identity
Create repository
https://console.aws.amazon.com/ecr/repositories
Simple form, just provide name of the private repo
account_id.dkr.ecr.us-west-2.amazonaws.com/reponame
Build docker image
git clone https://github.com/repo
docker build -t reponame:tag Dockerfile_location
Push Docker Image to AWS Repo
https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html
Let docker know how to login to ECR
aws ecr get-login-password --region us-west-2
#copy the token
docker login --username AWS account_id.dkr.ecr.us-west-2.amazonaws.com
#paste the token
List docker images and locate the one you built
docker images
Tag and push the image to ECR
docker tag image_id account_id.dkr.ecr.us-west-2.amazonaws.com/reponame:tag
docker push account_id.dkr.ecr.us-west-2.amazonaws.com/reponame:tag
Now you have an image in ECR
https://us-west-2.console.aws.amazon.com/ecr/repositories?region=us-west-2