Back to aws
aws#ecr#docker#aws

ECS Part 2: Create ECR Repository & Push Docker Image

Create a private image registry, authenticate Docker, tag & push. Four commands you'll use forever.

TechNotesHub Team August 2, 2026 2 views
Log in to download the attached PDF

Part 2 — ECR: Push your image

1. Create the ECR repository

AWS Console → search "ECR" → Repositories → Create repository:

  • Visibility: Private.
  • Name: my-ecr-repo.
  • Leave defaults → Create repository.

Note the repo URI, e.g.:

767398120915.dkr.ecr.us-east-1.amazonaws.com/my-ecr-repo

Replace 767398120915 with your account ID everywhere below.

2. Authenticate Docker to ECR

Click the repository → View push commands — AWS shows you the exact commands.

Or copy-paste:

aws ecr get-login-password --region us-east-1 \
  | docker login --username AWS \
    --password-stdin 767398120915.dkr.ecr.us-east-1.amazonaws.com

Expected: Login Succeeded.

3. Build the image (in the folder with your Dockerfile)

docker build -t my-ecr-repo .

4. Tag the image with the ECR URI

Docker's push needs the image name to match the destination.

docker tag my-ecr-repo:latest 767398120915.dkr.ecr.us-east-1.amazonaws.com/my-ecr-repo:latest

5. Push!

docker push 767398120915.dkr.ecr.us-east-1.amazonaws.com/my-ecr-repo:latest

You'll see the layers uploading. When done:

latest: digest: sha256:dd71... size: 948

6. Verify in the console

Refresh the ECR page → you should see one image tagged latest.

The 4 commands you'll use forever

# 1. Log in
aws ecr get-login-password --region <r> | docker login --username AWS --password-stdin <acct>.dkr.ecr.<r>.amazonaws.com
# 2. Build
docker build -t <name> .
# 3. Tag
docker tag <name>:latest <acct>.dkr.ecr.<r>.amazonaws.com/<name>:latest
# 4. Push
docker push <acct>.dkr.ecr.<r>.amazonaws.com/<name>:latest

Common issues

  • no basic auth credentials → forgot the login step or session expired (tokens last 12 h).
  • repository does not exist → typo in image tag; account ID / region wrong.
  • Slow first push → all layers are new. Subsequent pushes only send changed layers.

Best practice

  • Never push :latest in production. Tag with git SHA or version: :v1.4.2, :sha-abc123.
  • Enable image scanning on push (Console → Repository → Scan on push) — free vulnerability scan.
  • Set a lifecycle rule to auto-delete images older than 30 days → save on storage.

Keep reading

You may also like

Discussion (0)

No comments yet. Be the first to weigh in.

Leave a comment

Comments are reviewed before appearing.