Amazon ECR – The Registry Behind Every Container You Ship
A deep, practical walkthrough of Amazon Elastic Container Registry — how it stores images, moves bytes across the planet, protects your supply chain, and quietly powers ECS, EKS, and Lambda deployments at companies you use every day.
Picture a shipping port. Every container arriving or leaving has to pass through customs, get logged, get inspected, and get placed on the correct ship. The port doesn’t care what’s inside the container — clothes, electronics, food — it only cares about moving it safely, tracking it, and making sure nothing dangerous slips through. Amazon Elastic Container Registry, or ECR, is that port for your software containers. It doesn’t run your application; it stores, secures, scans, and delivers the container images that ECS, EKS, Fargate, and Lambda later run. Once you see ECR as infrastructure for a supply chain rather than “just a place to keep Docker images,” almost every design decision inside it starts to make sense.
1Beyond the Basics: What ECR Really Is
You already know a container image is a packaged application. ECR is where that package lives before and after it runs.
Amazon ECR is a fully managed OCI-compliant (Open Container Initiative) container registry. That single word, “managed,” is doing a lot of work. AWS operates the storage, the availability, the patching, and the scaling of the registry service itself — you never provision a server, size a disk, or configure a database for it. What you manage instead are repositories (logical folders that hold versions of one image), images (the actual packaged application layers), and the policies that control who can touch them.
Think of an ECR registry as an entire warehouse complex owned by your AWS account. Each repository inside it is one labeled shelf — say, “payments-api” or “fraud-detector.” Every time you push a new build, you’re placing a new, uniquely tagged box on that shelf, without removing the older boxes unless you tell the warehouse to clear them out.
ECR comes in two distinct flavors, and confusing them is one of the most common early mistakes teams make when they move past “just pushing to the default registry.”
Private Registry
One private registry is automatically created per AWS account per region. Access is controlled entirely through IAM and repository policies. This is where production workloads live.
Public Registry (ECR Public)
A separate, globally distributed registry for sharing images with the world — similar in spirit to Docker Hub — backed by a global content delivery layer so pulls are fast everywhere.
Pull-Through Cache Repository
A repository that transparently mirrors an upstream registry (like Docker Hub or Quay) the first time an image is requested, then serves it locally afterward.
Repository Namespace
Repositories can be organized with slash-delimited names such as team/service, letting you apply IAM conditions at the namespace level instead of per-repository.
A private registry is per-account, per-region — not per-repository. Every repository you create in a given region shares the same registry URI prefix, which is why the registry ID always matches your AWS account ID.
2Architecture and Core Components
ECR is built from a small set of primitives that combine to form the full picture.
Every image in ECR is described by a manifest — a JSON document listing the image’s configuration and the ordered list of filesystem layers that make it up. Layers themselves are content-addressed: each one is identified by a SHA-256 digest of its contents, and layers are stored once and shared across every image and repository that happens to contain identical bytes. This is why pushing a new version of an image that only changed its top layer is fast — the unchanged layers are already sitting in storage.
Registry
The account-and-region-scoped endpoint, addressed as {account-id}.dkr.ecr.{region}.amazonaws.com.
Repository
A named collection of related images, typically one per application or service.
Image Manifest
Describes the layers and configuration for one specific image, identified by a digest.
Tags
Human-friendly, mutable pointers (like v2.4.1 or latest) that reference a manifest digest.
Layers
Immutable, deduplicated filesystem blobs stored durably underneath the registry, backed by Amazon S3.
An important architectural nuance: a tag is not the image. It’s a label attached to a manifest digest, and that label can be moved. If two teams both push something tagged latest, the second push simply repoints the tag; the first image is not deleted, only unreachable by that name. This is precisely why serious production systems reference images by digest rather than by mutable tag whenever an exact, unambiguous version is required.
graph TD
A[Private Registry - one per account per region] --> B[Repository: payments-api]
A --> C[Repository: fraud-detector]
B --> D[Tag: v2.4.1]
B --> E[Tag: latest]
D --> F[Manifest Digest sha256:abc123]
E --> F
F --> G[Layer 1: base OS]
F --> H[Layer 2: runtime]
F --> I[Layer 3: app code]
ECR also integrates two supporting services at the architecture level that are easy to overlook: KMS for envelope encryption of stored layers, and VPC endpoints (specifically interface endpoints for ecr.api and ecr.dkr, plus a gateway endpoint for S3) that let private subnets pull images without ever routing through the public internet.
3Internal Working: What Actually Happens on Push and Pull
Understanding the protocol underneath the CLI commands explains almost every performance and permission question you’ll run into.
ECR speaks the standard Docker Registry HTTP API V2 (now formalized as the OCI Distribution Specification). This matters more than it sounds: it means any OCI-compliant client can talk to ECR without a proprietary SDK, and ECR can, in turn, act as a pull-through cache for other OCI-compliant registries.
Authentication is where ECR diverges most sharply from a self-hosted registry. Rather than storing a static username and password, ECR issues short-lived authorization tokens through the GetAuthorizationToken API, tied to your IAM identity. The token is valid for 12 hours, base64-encoded, and used as a Basic Auth credential for the actual Docker/OCI push and pull calls. This is why the familiar login step exists before every push — you are not logging into a separate account system, you are exchanging an IAM credential for a temporary registry credential.
sequenceDiagram
participant Dev as Developer / CI Runner
participant IAM as IAM
participant ECR as ECR Registry API
participant S3 as Backing Storage (S3)
Dev->>IAM: Assume role / use credentials
Dev->>ECR: GetAuthorizationToken
ECR-->>Dev: Short-lived token (12h)
Dev->>ECR: Push manifest + layers (docker push)
ECR->>ECR: Check layer digest exists already?
ECR->>S3: Store new layers only
ECR-->>Dev: Push acknowledged
On pull, the same token exchange happens, then the client requests the manifest for a given tag or digest, inspects which layers it doesn’t already have locally, and downloads only those. ECR performs a digest check on every layer at upload time; if a layer with an identical SHA-256 digest already exists anywhere in that registry, it is not re-uploaded, only referenced. This is the mechanism that makes multi-stage builds and shared base images so storage-efficient in practice.
Many engineers assume “docker login” against ECR creates a persistent session. It does not — the token expires in 12 hours, which is why long-running CI agents periodically see authentication failures if they cache credentials instead of re-authenticating per job.
4Data Flow and the Image Lifecycle
An image’s life doesn’t end at push — scanning, replication, and expiration all happen afterward, automatically if you configure them to.
A typical intermediate-level pipeline pushes an image, waits for or triggers a vulnerability scan, optionally replicates the image to other regions or accounts, and eventually expires old images through a lifecycle policy so storage costs don’t grow without bound.
Push
The CI/CD pipeline builds the image, tags it (often with the Git commit SHA and a semantic version), and pushes it to a repository. Immutable tag settings can be enabled per repository to prevent any tag from ever being overwritten.
Scan
ECR can run basic scanning (powered by Clair, on push or on a schedule) or enhanced scanning (powered by Amazon Inspector, continuous, covering OS packages and application-level dependencies). Findings are emitted as events that other services can react to.
Replicate
Replication rules copy images to other regions or other AWS accounts automatically after push, so a disaster-recovery region or a partner account always has a current copy without a separate pipeline step.
Expire
A lifecycle policy — a JSON rule set evaluated daily — automatically deletes images matching criteria such as “untagged for more than 14 days” or “keep only the most recent 20 tagged images matching a prefix.”
flowchart LR
A[CI/CD Build] --> B[Push to ECR Repository]
B --> C{Scan Enabled?}
C -->|Yes| D[Vulnerability Scan Findings]
C -->|No| E[Skip Scan]
D --> F[EventBridge Notification]
B --> G{Replication Rule Matches?}
G -->|Yes| H[Copy to Target Region/Account]
G -->|No| I[Stay in Source Only]
B --> J[Lifecycle Policy Evaluation - Daily]
J -->|Rule Matches| K[Image Expired and Deleted]
J -->|No Match| L[Image Retained]
5Advantages, Disadvantages, and Trade-offs
ECR is opinionated in ways that help most teams and occasionally frustrate the ones with unusual requirements.
Advantages
- Zero infrastructure to patch, scale, or back up — AWS operates the storage layer.
- IAM-native access control, meaning the same policy language secures ECR as secures EC2, S3, and Lambda.
- Deep native integration with ECS, EKS, Fargate, CodeBuild, and Lambda container images.
- Built-in vulnerability scanning without deploying a separate scanning tool.
- Cross-region and cross-account replication with a single declarative rule.
Disadvantages / Trade-offs
- No built-in image signing UI — signing requires wiring in Notation or Cosign plus KMS separately.
- Enhanced scanning (Inspector-based) carries an additional per-image cost beyond basic scanning.
- Cross-cloud portability is weaker than a registry-agnostic tool, since IAM-based auth doesn’t transfer outside AWS.
- Lifecycle policy rule ordering and prefix matching has a learning curve and can silently delete more than intended if misconfigured.
The trade-off in one sentence: you give up some registry-vendor flexibility in exchange for near-zero operational burden and IAM-level security that would take real engineering effort to replicate on a self-hosted registry.
6Performance and Scalability
Registry performance is mostly about where the bytes travel from, not how big the registry “is.”
Because ECR is backed by S3, it inherits S3’s practically unlimited storage scalability — you will never hit a “registry full” condition. The performance question that actually matters in production is pull latency at scale: what happens when 500 Fargate tasks all start at once and all need the same image?
Three levers keep pull performance predictable at scale. First, always pull from the same region your compute runs in — cross-region pulls add real latency and, in some architectures, data transfer cost. Second, keep images small and layer-efficient; multi-stage builds that discard build-time dependencies mean fewer bytes to transfer per cold start, which matters enormously for Fargate and Lambda where pull time is part of startup latency. Third, for very high-fanout scenarios (thousands of nodes pulling simultaneously), a pull-through cache combined with EKS’s built-in image pull policies reduces redundant external traffic and keeps the blast radius of an upstream outage contained to your own account.
Pulling an image cross-region is like ordering a package from an overseas warehouse when a local one has the same item — it works, but you pay in time and sometimes money you didn’t need to spend.
7High Availability and Reliability
ECR’s durability story is inherited almost entirely from S3, with replication adding a second, independent layer of resilience.
Within a region, ECR storage is designed for the same eleven-nines durability characteristic of S3, spread across multiple Availability Zones automatically — you do nothing to configure this. The reliability question intermediate teams actually need to plan for is regional failure: if an entire AWS region becomes unavailable, can your deployment pipeline still pull the images it needs elsewhere?
This is exactly what cross-region replication rules solve. Configured once at the registry level, they continuously copy new pushes to one or more destination regions, so a failover region’s ECS or EKS cluster can pull from a local, already-populated repository instead of waiting on a manual copy during an incident.
| Failure Scenario | ECR Behavior / Mitigation |
|---|---|
| Single Availability Zone outage | No impact — storage and API are Multi-AZ by default |
| Regional outage | Requires pre-configured cross-region replication to a healthy region |
| Account-level misconfiguration | Mitigated by cross-account replication to a separate, isolated account |
| Accidental image deletion | Mitigated by tag immutability plus a separate backup/replica repository |
8Security: The Layer That Matters Most
ECR sits at the front door of your production supply chain, which makes its security model worth understanding in real depth.
Security in ECR operates on three simultaneous layers: identity (who is asking), network (where the request is coming from), and content (what’s actually inside the image).
IAM Policies
Control which principals can call which ECR API actions — push, pull, delete, describe — evaluated the same way as any other AWS service.
Repository Policies
Resource-based policies attached directly to a repository, useful for granting cross-account pull access without modifying the consumer’s IAM role.
VPC Interface Endpoints
Keep push/pull traffic entirely inside AWS’s network backbone, avoiding the public internet path for private subnets.
Image Scanning
Basic (Clair) or Enhanced (Inspector) scanning surfaces known CVEs in OS packages and, with enhanced scanning, application-layer dependencies too.
Encryption at rest is automatic: every repository is encrypted using either AES-256 with an AWS-managed key, or a customer-managed KMS key when you need auditable, revocable control over the encryption key itself. Encryption in transit is enforced through TLS on every API call and every layer transfer — there is no plaintext option.
Problem
Granting ecr:* on * resources to a CI/CD role “to keep things simple.”
Why It’s Harmful
A single compromised pipeline credential can then push malicious images to every repository in the account, or delete production images outright, with no resource-level boundary to contain the blast radius.
Correct Approach
Scope IAM policies to specific repository ARNs and specific actions (typically push-only for build pipelines, pull-only for deployment roles), and use repository policies for any cross-account access instead of broad wildcard grants.
Treating a passed vulnerability scan as a one-time gate. New CVEs are discovered constantly, so an image that was “clean” at push time can become vulnerable weeks later — this is precisely why continuous, enhanced scanning exists rather than only on-push scanning.
9Monitoring, Logging, and Metrics
Visibility into a registry means answering two questions: who touched it, and what happened to the content.
AWS CloudTrail
Records every ECR API call — every push, pull, delete, and policy change — with the calling identity, timestamp, and source IP, forming the audit trail for compliance and incident response.
Amazon CloudWatch
Publishes registry-level metrics like storage usage and API call counts, useful for cost tracking and catching abnormal push/pull volume.
Amazon EventBridge
Emits events for image push completions and scan-finding results, which can trigger downstream automation such as blocking a deployment when a critical CVE is found.
Inspector Findings Dashboard
Centralizes enhanced-scan vulnerability findings across every repository, ranked by severity, for teams running enhanced scanning fleet-wide.
A mature setup wires these together: an EventBridge rule watches for scan findings above a severity threshold, invokes a Lambda function that tags the image as blocked, and CloudTrail confirms nobody bypassed that block by pushing directly to a production tag afterward.
10Deployment and Cloud Integration
ECR rarely operates alone — its real value shows up in how tightly it plugs into the rest of the AWS container ecosystem.
Amazon ECS and Fargate
Task definitions reference an ECR image URI directly; the ECS agent (or Fargate’s managed control plane) authenticates using the task’s IAM role and pulls automatically at task launch.
Amazon EKS
Kubelet on each node authenticates to ECR via an IAM role mapped through IRSA (IAM Roles for Service Accounts) or the node’s instance role, pulling images referenced in pod specs.
AWS Lambda Container Images
Lambda can run a function packaged as a container image up to 10 GB, pulled directly from ECR at cold start — this is why image size directly affects cold-start latency for container-based functions.
CI/CD (CodeBuild, CodePipeline, GitHub Actions)
Build stages authenticate to ECR, push a freshly built image tagged with the commit SHA, and the deploy stage updates the target service to reference that new tag or digest.
flowchart TD
A[Git Push] --> B[CodeBuild / CI Runner]
B --> C[Build Image]
C --> D[Push to ECR Repository]
D --> E[EventBridge: Push Event]
E --> F[CodePipeline Deploy Stage]
F --> G[ECS Service Update]
F --> H[EKS Rolling Deployment]
F --> I[Lambda Function Update]
11Design Patterns and Anti-Patterns
The way teams structure repositories and tags predicts, almost reliably, how painful their rollbacks will be.
Pattern: Immutable Tags
Enable tag immutability so once v2.4.1 is pushed, it can never be silently overwritten — any change requires a genuinely new tag, preserving a trustworthy audit trail.
Pattern: One Repository Per Service
Keeps IAM scoping, lifecycle policies, and replication rules clean and independently tunable per service rather than one giant shared repository with mixed access needs.
Pattern: Digest-Pinned Production Deployments
Production task definitions and manifests reference the image by digest, not by mutable tag, guaranteeing exactly the same bytes run in every environment that references that digest.
Problem
Deploying production workloads against the latest tag.
Why It’s Harmful
latest is mutable by definition — a completely unrelated push can silently change what “latest” points to, making rollbacks and audits unreliable and turning “which version is actually running” into a guessing game.
Correct Approach
Tag with a semantic version or Git commit SHA, and reference that specific tag (or its digest) in deployment manifests. Reserve latest purely for local development convenience.
Problem
No lifecycle policy at all, letting every build from every branch accumulate forever.
Why It’s Harmful
Storage costs grow indefinitely, and — more dangerously — old, unscanned or since-vulnerable images remain pull-able, which widens the attack surface if any credential leaks.
Correct Approach
Apply a lifecycle policy that expires untagged images quickly (days, not months) and caps tagged image retention per prefix (for example, keep only the most recent N release tags).
12Best Practices and Common Mistakes
Most ECR incidents trace back to a handful of repeatable, avoidable oversights.
Advantages
- Enable enhanced scanning on any repository handling externally facing or sensitive workloads.
- Use repository policies instead of broadened IAM roles for cross-account sharing.
- Pull through VPC interface endpoints in private-subnet architectures.
- Set lifecycle policies from day one, not after storage costs become a surprise line item.
Disadvantages / Trade-offs
- Forgetting to re-authenticate CI credentials before the 12-hour token expires.
- Sharing one IAM role across build and deploy stages, blurring push and pull permission boundaries.
- Ignoring scan findings because no automated gate blocks deployment on critical CVEs.
- Cross-region replication configured only after a regional incident already exposed the gap.
13Real-World and Industry Examples
ECR’s design choices become clearer once you see the scale of problem they were built to solve.
Streaming and Media Platforms
Large streaming platforms running thousands of microservices on ECS and EKS rely on ECR’s regional replication so that a deployment in one region never waits on a cross-region pull during a scale-out event, keeping autoscaling responsive under sudden traffic spikes.
Financial Services
Banks and fintechs commonly pair ECR’s enhanced scanning with a hard EventBridge-triggered deployment gate, refusing to promote any image with an unresolved critical vulnerability — turning a manual security review step into an automated, auditable control.
Software Vendors Distributing Publicly
Companies distributing open-source or partner-facing tools use ECR Public to host container images with the reliability of AWS’s backbone, without asking end users to authenticate at all for a pull.
Multi-Account Organizations
Enterprises using AWS Organizations frequently centralize a “golden image” repository in a shared services account, replicating approved base images outward to every workload account via cross-account replication rules, rather than letting each team build its own untrusted base image.
14Frequently Asked Questions
Questions that come up constantly once teams move past the “hello world” push and start operating ECR for real.
Pulls from ECR into compute services within the same region do not incur the standard cross-region data transfer charges; you are billed primarily for the storage the images occupy and, for enhanced scanning, per-image scan costs.
No — ECR does not support renaming a repository in place. The common workaround is creating a new repository with the desired name and using replication or a manual copy to migrate the images across.
Basic scanning runs a one-time or on-push check using the open-source Clair engine, focused on OS package CVEs. Enhanced scanning, powered by Amazon Inspector, runs continuously, covers both OS and application-level (language package) dependencies, and automatically rescans when new vulnerabilities are published.
No — enabling immutability only protects tags pushed after the setting is turned on. Tags that already existed remain exactly as mutable or immutable as they were before the change.
Replication proactively copies images you already own to another region or account after every push. A pull-through cache instead lazily mirrors images from an external upstream registry only the first time someone requests them — it’s for consuming outside images efficiently, not distributing your own.
15Summary and Key Takeaways
Amazon ECR is far more than a bucket for Docker images. It is an IAM-integrated, encryption-by-default, OCI-compliant registry whose real engineering surface lives in the details: how tokens are exchanged, how layers deduplicate, how lifecycle policies quietly control cost and attack surface, and how replication turns a single-region service into a resilient, multi-region supply chain. Treating those details deliberately — immutable tags, digest-pinned deployments, scoped IAM, continuous scanning — is what separates teams who merely use ECR from teams who operate it safely at scale.
Key Takeaways
- Registry vs. Repository vs. Image — one registry per account per region, many repositories inside it, many tagged images inside each repository.
- Tags are mutable pointers — always deploy production workloads by digest or an immutable tag, never by a floating tag like
latest. - Authentication is token-based, not password-based — tokens expire every 12 hours, which shapes how CI/CD pipelines must be designed.
- Layers deduplicate automatically — identical content is stored once, which is why small, well-layered images push and pull faster.
- Security is three-layered — identity through IAM/repository policies, network through VPC endpoints, and content through vulnerability scanning.
- Lifecycle policies aren’t optional at scale — without them, storage costs and stale, vulnerable images both accumulate silently.
- Replication is your regional resilience story — configure it before an incident forces you to, not during one.



