Lesson 294·M25 Docker / DevOps / Infrastructure
ECR
OpenLearning Objectives
By the end of this lesson you should be able to:
- Explain the repositories: the image homes (L294)
- Explain the push and the pull: the CI and the runtimes (L294)
- Explain the tags: the versions and the immutability (L294)
- Explain the scans: the vulnerability checks (L293)
- Explain the AI shape: the image's AWS home (L294)
One-Line Definition
The ECR is the AWS image registry (L294) — the repositories (the image homes: ai-service with the tags, L294), the push and the pull (the CI L296 pushes the image, the ECS L295 and the k8s L306 pull it, L294), the tags (the versions and the immutability, L294), and the scans (the vulnerability checks with the findings, L293) — the image's AWS home, between the build (L289) and the run (L295).
The one-sentence interview answer: "The ECR is AWS's container registry (L294). The repository (L294): the image's home — ai-service — holding the tags (L294): the versions — 1.2.3, the commit SHAs — abc1234 (L291) — with the immutability (L294) — a tag can't be overwritten (L294). The push (L294): the CI (L296) builds the image (L289) and pushes it (L294) — authenticated by the IAM (L262). The pull (L294): the ECS (L295) and the Kubernetes (L306) pull the image by the tag (L294). The scans (L293): the ECR scans the image (L294) for the vulnerabilities (L293) — the findings (L293) surfaced in the console and the CI (L296). The lifecycle (L294): the retention policies (L294) clean up the old tags (L294) — the repo stays lean (L294). The AI shape (L173): the CI (L296) pushes the service's image (L289) to the ECR (L294), the scan (L293) gates, and the ECS (L295) pulls the pinned tag (L291) — the image's AWS home, between the build (L289) and the run (L295) (L294)."
Mental Model
Think of the ECR as the warehouse with the numbered shelves. The warehouse (the ECR, L294) stores the crates (the images, L288) on the labeled shelves (the repositories, L294): the ai-service shelf (L294), the worker shelf (L294). Each crate has the labels (the tags, L294): the version — 1.2.3 — and the batch number — abc1234 (L291) — and the labels are locked (the immutability, L294): a crate can't be relabeled (L294). The delivery trucks (the CI, L296) drop off the new crates (the pushes, L294), and the stores (the ECS, L295) order the crates by the labels (the pulls, L294). The warehouse's inspectors (the scans, L293) check each crate for the damage (the vulnerabilities, L293) and flag the findings (L293). And the warehouse's manager (the lifecycle, L294) clears the old crates (the retention, L294) — the shelves stay lean (L294).
the warehouse (the ECR, L294)
┌────────────────────────────────────────────────────────┐
│ the shelves (the repositories, L294) — the image homes │
│ the labels (the tags, L294) — pinned, immutable (L294) │
│ the trucks (the CI, L296) — the pushes (L294) │
│ the inspectors (the scans, L293) — the findings (L293) │
└────────────────────────────────────────────────────────┘
The mental model is the warehouse: the shelves, the labels, the trucks, and the inspectors (L294).
Visual Flow — One Image Through the Registry
the commit (L296)
│ the build (L289)
▼
┌────────────────────── THE PUSH (L294) ─────────────────────────────┐
│ the CI (L296): docker build → docker push (L294) │
│ the auth: the IAM (L262) · the repo: ai-service (L294) │
│ the tag: abc1234 (the commit SHA, L291) │
└──────────────────────────┬───────────────────────────────────────┘
▼
┌────────────────────── THE SCAN (L293) ─────────────────────────────┐
│ the ECR scans the image (L294) — the findings (L293) │
│ the critical CVEs → the gate (L293) │
└──────────────────────────┬───────────────────────────────────────┘
▼
┌────────────────────── THE PULL (L294) ─────────────────────────────┐
│ the ECS (L295) pulls ai-service:abc1234 (L294) │
└──────────────────────────────────────────────────────────────────┘
The flow is the image's life: push → scan → pull (L294).
How It Works — The Registry, Part by Part
- The repositories (L294). The image homes (L294): one per service (L294) — the
ai-service, theworker(L294) — holding the tags (L294). - The push and the pull (L294). The CI (L296) builds (L289) and pushes (L294) — authenticated by the IAM (L262); the ECS (L295) and the k8s (L306) pull by the tag (L294).
- The tags (L294). The versions and the commit SHAs (L291):
1.2.3,abc1234(L294) — with the immutability (L294): the tag can't be overwritten (L294) — the deployed tag (L294) is the exact image (L294). - The scans (L293). The ECR scans the image (L294) for the vulnerabilities (L293) — the findings (L293) surfaced (L294), the CI (L296) gated (L293).
- The lifecycle (L294). The retention policies (L294) — the old tags (L294) cleaned up (L294) — the repo lean (L294).
Note
The tag is the deployment's contract (L294). The senior answer treats the tag (L294) as the contract (L294): the deployed tag (L294) is the exact image (L294) — the abc1234 (L294) the CI (L296) pushed (L294), the same abc1234 the ECS (L295) pulled (L294) — the reproducible deployment (L298). The latest (L291) breaks the contract (L294): two runs, two different images (L294). The pin (L291) is the contract (L294).
Real Project Usage
- A CI pipeline (L296). The workflow (L297) builds (L289) and pushes (L294) to the ECR (L294) — the tag is the commit SHA (L291).
- An ECS service (L295). The ECS (L295) pulls the pinned tag (L291) from the ECR (L294) — the deployed image (L294) exact (L294).
- A Kubernetes deployment (L306). The k8s (L306) pulls the image (L294) by the tag (L294).
- A scan gate (L293). The ECR's scan (L294) findings (L293) fail the CI (L296) — the critical CVEs (L293) never ship (L307).
- Anything shipped (L307). The pipeline (L307) pushes to the registry (L294) — the image's AWS home (L294).
The through-line: the registry is the image's home — between the build (L289) and the run (L295) (L294).
Interview Explanation
Say it in four moves:
- The repositories. "The image homes — one per service (L294)."
- The push and the pull. "The CI pushes (L296), the ECS pulls (L295)."
- The tags. "The versions and the SHAs — immutable (L294)."
- The scans. "The vulnerability checks with the findings (L293)."
Senior-Level Insights
- The tag is the contract (L294). The pinned tag (L291) — the deployed image (L294) exact (L294) — the reproducible deployment (L298).
- The immutability is the trust (L294). The tag can't be overwritten (L294) — the deployed
abc1234(L294) is the testedabc1234(L296) (L294). - The scan is the gate (L293). The ECR's findings (L294) — the CI gate (L293) — the known CVE (L293) never ships (L307).
- The IAM is the access (L262). The push and the pull (L294) — the IAM (L262) scoped: the CI's role pushes (L262), the ECS's role pulls (L262).
- The lifecycle is the cost (L294). The retention policies (L294) — the old tags (L294) cleaned — the storage (L285) lean (L294).
Common Mistakes
- The latest tag (L291). The
:latestpull (L291) — the contract (L294) broken; the pin (L291) is the contract (L294). - The mutable tags (L294). The tag overwritten (L294) — the immutability (L294) is the trust (L294).
- The scan ignored (L293). The findings (L293) un-gated (L293) — the known CVE (L293) ships (L307).
- The wide IAM (L262). The role with the registry access everywhere (L262) — the scoped push and pull (L262) are the least privilege (L262).
- The repo bloat (L294). The old tags accumulating (L294) — the retention policy (L294) is the cleanup (L294).
Best Practices
- Pin the tags (L291) — the deployment's contract (L294).
- Turn on the immutability (L294) — the tag can't be overwritten (L294).
- Gate on the scans (L293) — the critical CVEs fail the CI (L296).
- Scope the IAM (L262) — the CI's push, the runtime's pull (L262).
- Clean the lifecycle (L294) — the retention policies (L294).
Interview Questions
Q: Walk me through the ECR.
A: The AWS image registry (L294). The repositories — the image homes (L294). The push and the pull — the CI (L296) pushes, the ECS (L295) pulls (L294). The tags — the versions and the SHAs, immutable (L294). And the scans — the vulnerability checks (L293).
Q: Why pin the tag?
A: The contract (L294): the deployed tag (L294) is the exact image (L294) — the
abc1234the CI (L296) pushed (L294), the sameabc1234the ECS (L295) pulled (L294). Thelatest(L291) breaks the contract (L294): two runs, two different images (L294).
Q: How do the images get to the ECR?
A: Through the CI (L296): the workflow (L297) builds the image (L289) and pushes it (L294) — authenticated by the IAM (L262), tagged with the commit SHA (L291). The ECS (L295) and the k8s (L306) pull by the tag (L294).
Q: How do you keep the known vulnerabilities out?
A: The scan (L293): the ECR scans the image (L294) and surfaces the findings (L293); the CI (L296) gates on the critical CVEs (L293) — the build fails (L296) and the vulnerable image (L293) never ships (L307).
Follow-Up Questions
- What's a repository (L294)?
- What's the push and the pull (L294)?
- Why pin the tag (L294)?
- What's the immutability (L294)?
- How do the scans gate (L293)?
Comparison Table — ECR vs a Local Registry
| The ECR (L294) | The local registry (L294) | |
|---|---|---|
| The home (L294) | the AWS repositories (L294) | the local disk (L294) |
| The access (L262) | the IAM (L262) | the open (L294) |
| The scan (L293) | the built-in findings (L294) | none (L293) |
| The availability (L261) | the AWS regions (L261) | the one host (L294) |
| The use (L294) | the production (L307) | the dev (L290) |
The senior read: the ECR is the production home — the IAM, the scans, the regions (L294).
Code Example — The Push and the Pull
// The registry flow (L294) — the CI pushes, the runtime pulls (L294).
// 1 · THE AUTH (L262) — the scoped IAM (L262).
// aws ecr get-login-password --region us-east-1 \
// | docker login --username AWS --password-stdin \
// 123456789012.dkr.ecr.us-east-1.amazonaws.com
// 2 · THE PUSH (L294) — the CI (L296) builds and pushes (L294).
// docker build -t ai-service:abc1234 .
// docker tag ai-service:abc1234 \
// 123456789012.dkr.ecr.us-east-1.amazonaws.com/ai-service:abc1234
// docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/ai-service:abc1234
// 3 · THE SCAN (L293) — the findings gate the CI (L296).
// the critical CVEs → the build fails (L293)
// 4 · THE PULL (L294) — the ECS (L295) pulls the pinned tag (L291).
// the task's image:
// 123456789012.dkr.ecr.us-east-1.amazonaws.com/ai-service:abc1234
What the reader must SEE — the flow, declared:
get-login-password + login → the IAM auth (L262)
build + tag + push → the CI push (L296, L294)
the commit-SHA tag → the pin (L291)
the scan gate → the CVE check (L293)
the ECS pulls the same tag → the contract (L294)
The build pushes, the scan gates, the runtime pulls (L294).
Tip
The pair that defines the ECR: the commit-SHA tag (the contract, L291) and the scan gate (the supply chain's check, L293). Push the pinned tag, scan it, pull the same bytes — the image's AWS home (L294).
Performance Notes
- The registry is the pull's speed (L294). The image (L288) from the region (L261) — the ECS (L295) pulls fast (L294).
- The cache is the push's speed (L289). The layers (L289) cached in the registry (L294) — the unchanged layers (L289) not re-pushed (L294).
- The scan is the gate's time (L293). The scan step (L293) — the seconds (L293) for the gate (L296).
- The retention is the storage's cost (L294). The old tags (L294) — the retention policy (L294) keeps the bill (L285) lean (L294).
Debugging Scenarios
| Symptom | First check (L294) | The lever |
|---|---|---|
| The push is denied | The IAM (L262) | The push permission (L262) |
| The pull fails | The tag (L291) | The pinned tag (L291) |
| The deployed image differs | The latest (L291) | The immutable pin (L294) |
| The known CVE ships | The scan (L293) | The CI gate (L296) |
| The repo bloats | The retention (L294) | The lifecycle policy (L294) |
Quick Revision Notes
- The ECR = the AWS image registry (L294): the repositories, the push and the pull, the tags, the scans.
- The repositories: the image homes — one per service (L294).
- The push and the pull: the CI pushes (L296), the ECS pulls (L295).
- The tags: the versions and the SHAs — immutable (L294).
- The scans: the vulnerability checks (L293) — the CI gate (L296).
Cheat Sheet
ECR = the AWS image registry — the image's AWS home
THE REPOSITORIES (L294)
the image homes — one per service (L294)
the tags inside (L294)
THE PUSH AND THE PULL (L294)
the CI (L296) builds (L289) and pushes (L294)
the ECS (L295) and the k8s (L306) pull by the tag (L294)
THE TAGS (L294)
the versions (L294) · the commit SHAs (L291)
the immutability (L294) — the tag can't be overwritten (L294)
the deployed tag = the exact image (L294)
THE SCANS (L293)
the vulnerability findings (L293)
the critical CVEs gate the CI (L296)
THE LIFECYCLE (L294)
the retention policies (L294) — the old tags cleaned (L294)
INTERVIEW, 4 MOVES
1 repositories "the image homes (L294)"
2 push/pull "the CI pushes, the ECS pulls (L294)"
3 tags "the SHAs, immutable (L291, L294)"
4 scans "the vulnerability checks, the gate (L293)"Key Takeaways
Recap
- The ECR is the AWS image registry (L294): the repositories (L294), the push and the pull (L294), the tags (L294), and the scans (L293)
- The repositories (L294) are the image homes — one per service (L294) — holding the tags (L294)
- The push and the pull (L294): the CI (L296) builds (L289) and pushes (L294), authenticated by the IAM (L262); the ECS (L295) and the k8s (L306) pull by the tag (L294)
- The tags (L294) are the versions and the commit SHAs (L291) — with the immutability (L294): the tag can't be overwritten, so the deployed tag is the exact image (L294)
- The scans (L293) check the image for the vulnerabilities (L293) — the findings (L293) gate the CI (L296)
- The AI shape (L294): the CI (L296) pushes the service's image (L289) to the ECR (L294), the scan (L293) gates, and the ECS (L295) pulls the pinned tag (L291) — the image's AWS home, between the build (L289) and the run (L295) (L294)
Check your understanding
Answer each one out loud. Then rate yourself honestly.
0/8What's a repository (L294)?
What's the push and the pull (L294)?
Why pin the tag (L294)?
What's the immutability (L294)?
How do the scans gate (L293)?
What's the IAM's role (L262)?
What's the lifecycle for (L294)?
What is the image's AWS home (L294)?
A Closing Note — The Warehouse, Stocked
You now hold the registry: the repositories, the push and the pull, the tags, and the scans — with the pin as the contract. The image has its AWS home — and the shelves are labeled (L294).
Next: running the containers without the servers — ECS & Fargate (L295).