goharbor/harbor

Allow replication without auto-creating repositories on target registry (ECR templates support)

Open

#22842 opened on Feb 12, 2026

View on GitHub
 (2 comments) (1 reaction) (0 assignees)Go (28,490 stars) (5,235 forks)batch import
help wantedkind/requirementreplication/adapters

Description

Is your feature request related to a problem? Please describe. When replicating images from Harbor to AWS ECR, Harbor checks if a repository exists and automatically creates it if it does not. This breaks AWS ECR repository creation templates, because ECR templates are only applied when the repository is created automatically by ECR itself (create-on-push). As a result, replicated repositories are created with default settings instead of the expected configuration (immutability, lifecycle policies, encryption, tags, etc.).

Describe the solution you'd like Add an optional replication setting like “Create repository if not exists” (enabled by default for backward compatibility). When disabled, Harbor should not call CreateRepository on the target registry. Harbor should attempt to push images directly and let the target registry auto-create the repository. If creation templates are not enabled the replication will fail with "repository not found".

Describe the main design/architecture of your solution

  • create_repository_if_not_exists: true|false (default: true)

Behavior:

  • If true: current behavior (Harbor checks and creates repo if missing)
  • If false: Harbor skips repository creation and attempts push directly
  • If push fails with "repository not found", return error and rely on remote-side auto-creation features

UI:

  • Checkbox in replication rule: [x] Create repository if not exists on target registry

Describe the development plan you've considered

  • Add config flag to replication policy model and API
  • Update replication executor logic to skip CreateRepository when disabled
  • UI checkbox in replication rule settings
  • Default to current behavior to avoid breaking existing setups
  • Basic tests with ECR

Contributor guide