Harbor — Fundamentals
What is Harbor?
| Harbor (self-hosted) | ECR/ACR/GCR | Docker Hub |
|---|
|---|---|---|---|
| Cost | Storage cost only | Storage + transfer fees | Free/paid tier |
|---|---|---|---|
| Air-gapped | Yes | No | No |
| RBAC | Project-based, LDAP/AD | IAM policies | Organisation teams |
| Vulnerability scan | Trivy built-in | ECR Inspector, ACR Tasks | Docker Scout (paid) |
| Multi-cloud | Yes — one registry for all | Cloud-specific | Universal but rate-limited |
Real scenario — air-gapped telco: a network management platform at a major telco runs in a data centre with no internet access. The development pipeline pushes images to an internet-facing Harbor. A replication rule syncs production-tagged images to the air-gapped Harbor inside the customer network every 4 hours. Production pods pull from the local registry — zero internet dependency, full vulnerability scanning in both environments.
Key Features
Image Signing
Image signing with Cosign answers: was this image actually built by our CI/CD? An attacker could push a malicious image with the same tag, and without signing, Kubernetes can't tell the difference. With Cosign plus a Kyverno policy, any unsigned image is rejected at the cluster level.
Harbor Architecture and Components
| Component | What it does |
|---|
|---|---|
| Registry | Core Docker registry — stores image layers and manifests |
|---|---|
| Core | API server — handles all Harbor API calls, authentication, RBAC |
| Portal | Web UI — project management, vulnerability reports, replication |
| Database (PostgreSQL) | Stores metadata, users, policies, scan results |
| Redis | Job queue for async operations (replication, scanning) |
| Trivy / Clair | Vulnerability scanner — scans images on push or schedule |
| Notary | Content trust — signs images so only signed images can be deployed |
Install Harbor on Kubernetes with Helm:
Projects, RBAC, Vulnerability Scanning
Every image in Harbor lives in a Project — Public (anyone can pull) or Private (requires authentication). RBAC is per-project: a developer can push to their team's project but not to production. Projects also carry policies for vulnerability scanning, content trust, and tag retention.
Vulnerability scanning — scan on push. Configure Harbor to automatically scan every image pushed to a project, and set a policy to prevent deployment of images with HIGH or CRITICAL vulnerabilities — when a cluster tries to pull a flagged image, Harbor's admission webhook rejects it before the pod starts.
| Scan trigger | When it runs |
|---|
|---|---|
| Scan on push | Automatic scan when an image is pushed — catches new images immediately |
|---|---|
| Scheduled scan | Re-scans all images on a schedule — catches newly-discovered CVEs in old, already-pushed images |
| Manual scan | Triggered from the UI or API for specific images |
Replication — sync images across registries. Harbor can replicate images between registries, either push-based (Harbor pushes to the target when an image is pushed) or pull-based (Harbor pulls from the source on a schedule). Common uses: replicate from a dev registry to a production registry, replicate from a cloud registry to an on-premise Harbor, or maintain a disaster-recovery copy in a second region.
Interview Questions
Why would you run your own Harbor registry instead of using ACR or ECR?
Four compelling reasons. First, air-gapped environments — banks, defence, and telcos often run in networks with no internet access at all, and a cloud-hosted registry simply isn't reachable; Harbor can run entirely inside that isolated network. Second, multi-cloud consistency — a team running workloads across AWS, Azure, and GCP simultaneously would otherwise need to manage ECR, ACR, and GCR separately with different tooling and RBAC models; Harbor provides one consistent registry across all of them. Third, cost at scale — cloud registries charge storage plus data-transfer fees that grow with usage, while Harbor's cost is largely just the storage itself, since data transfer within your own infrastructure is free. Fourth, built-in vulnerability scanning and image signing without needing separate paid add-ons — Trivy and Notary/Cosign integration come with Harbor directly, rather than being a separate, additional service to configure and pay for on top of the base registry.

