AWS Elatic Container Registry

Table of contents
  1. Pushing image to ECR
    1. Authenticate Docker
    2. Build or tag image
    3. Push image

Pushing image to ECR

Authenticate Docker

First you must authenticate Docker to push to your ECR registry.

You must first configure AWS CLI with your credentials.

aws ecr get-login-password --profile ${profile} |
  docker login --username AWS --password-stdin ${account_id}.dkr.ecr.${region}.amazonaws.com

<account_id>.dkr.ecr.<region>.amazonaws.com is the URI of your ECR registry.

Authentication is only valid for 12 hours.

Build or tag image

Your image must have a tag that matches the URI of your ECR registry.

docker build -t ${account_id}.dkr.ecr.${region}.amazonaws.com/${repo_name}:${tag} . -f Dockerfile
# OR
docker tag ${image_id} ${account_id}.dkr.ecr.${region}.amazonaws.com/${repo_name}:${tag}

Push image

docker push ${account_id}.dkr.ecr.${region}.amazonaws.com/${repo_name}:${tag}

References: