Sub topic 15
Choosing a registry for your workload
This chapter assumes you have pushed and pulled images with both GHCR and Amazon ECR, and that you know how Kubernetes uses image pull secrets or node IAM roles. Here you compare the options and pick one.
Start with where the workload runs
A registry works best close to the systems that pull from it. Pulls inside the same cloud use that cloud's identity system, so you store no long-lived passwords.
- AWS (ECS, EKS, Lambda): ECR is the natural choice. Nodes and tasks authenticate with IAM roles. Lambda container images must be stored in ECR.
- Azure or Google Cloud: Azure Container Registry and Google Artifact Registry play the same role for their platforms.
- Mixed or outside the cloud: GHCR or a self-hosted registry avoids tying images to one provider.
Compare the main options
| Registry | Authentication | Strengths | Watch for |
|---|---|---|---|
| GHCR | GitHub token, including `GITHUB_TOKEN` in Actions | Lives next to your code and CI. Permissions follow GitHub repositories and organizations. | Cloud runtimes need a pull secret. Scanning and retention features are limited compared with ECR. |
| Amazon ECR | IAM, with 12-hour login tokens | Tag immutability, scan on push, lifecycle policies, IAM-based access. | Registry host is tied to an account and region. Cross-region use needs replication. |
| Docker Hub | Docker account or access token | Largest public catalog. Familiar to everyone. | Pull rate limits apply, especially to anonymous users. |
| ACR / Artifact Registry | Azure or Google identity | Native integration with their clouds. | Same lock-in trade-off as ECR. |
| Harbor or other self-hosted | Your own users, robot accounts, or OIDC | Full control and on-premises placement. | You run, patch, back up, and scale it yourself. |
Weigh the trade-offs
- Identity. Prefer a registry whose credentials your platform already issues. IAM roles for ECR are short-lived and are not copied into secrets.
- Controls on image content. If you need tag immutability, scanning, and automatic cleanup in one place, ECR provides all three as repository settings.
- Developer workflow. If your code and pipelines are on GitHub, GHCR removes a second set of accounts and lets CI publish without a personal access token.
- Cost and traffic. Pulls that cross regions or leave the cloud can add data transfer charges. Check current pricing for your case.
- Operations. Self-hosting trades license and storage costs for maintenance work. Choose it for compliance or network reasons, not for savings alone.
Using more than one
Many teams publish to GHCR from CI and replicate to ECR for production. Another common pattern is to pull third-party images such as nginx once and copy them into your own registry, so Docker Hub limits or outages cannot block a deploy. Whatever you choose, pin deployments to digests so a copy cannot differ from what you tested.
Exercise
A team runs all services on EKS in one AWS account. Their code is on GitHub, and security requires immutable tags and automatic scanning. Which registry fits best, and why?
Show answer
Amazon ECR. EKS nodes pull with IAM roles, so no pull secrets are needed, and ECR offers tag immutability and scan on push as repository settings. CI can still run on GitHub Actions and push to ECR.