DockerSécuritéDevOpsCI/CD

Docker Registry privé : héberger et sécuriser ses images avec Harbor

19 septembre 2026 · Sphinx-Digital

Docker Hub est pratique pour les images publiques. Pour les images privées en production, héberger son propre registry apporte le contrôle, la conformité et la performance. Harbor est le registry open source de référence.

Pourquoi Harbor plutôt que le registry officiel Docker ?

Le registry officiel (registry:2) est minimaliste — il stocke des images et c’est tout. Harbor ajoute :

  • Interface web et RBAC par projet
  • Scanning de vulnérabilités (Trivy intégré)
  • Réplication entre registries
  • Signature d’images (Cosign/Notary)
  • Proxy cache vers Docker Hub, GCR, ECR
  • Audit logs complets

Installer Harbor avec Docker Compose

# Télécharger Harbor
wget https://github.com/goharbor/harbor/releases/download/v2.10.0/harbor-online-installer-v2.10.0.tgz
tar xzvf harbor-online-installer-v2.10.0.tgz
cd harbor

# Copier et éditer la configuration
cp harbor.yml.tmpl harbor.yml
# harbor.yml (extraits importants)
hostname: registry.example.com

https:
  port: 443
  certificate: /etc/harbor/certs/fullchain.pem
  private_key: /etc/harbor/certs/privkey.pem

harbor_admin_password: votre-mot-de-passe-admin

database:
  password: db-password

data_volume: /data/harbor

trivy:
  ignore_unfixed: false
  skip_update: false
./install.sh --with-trivy

Configurer Docker pour utiliser Harbor

# Se connecter au registry privé
docker login registry.example.com

# Pousser une image
docker build -t myapp:1.0 .
docker tag myapp:1.0 registry.example.com/production/myapp:1.0
docker push registry.example.com/production/myapp:1.0

# Dans Kubernetes — configurer le imagePullSecret
kubectl create secret docker-registry harbor-credentials   --docker-server=registry.example.com   --docker-username=robot-ci   --docker-password=robot-token   -n production
# Utiliser le secret dans un Pod
spec:
  imagePullSecrets:
    - name: harbor-credentials
  containers:
    - image: registry.example.com/production/myapp:1.0

Scanning automatique avec Trivy

Harbor scanne automatiquement les images à chaque push. Vous pouvez configurer des règles pour bloquer les images avec des vulnérabilités critiques.

Harbor → Configuration → Vulnerability
→ Prevent vulnerable images from running (CVSS > 9.0)
→ Automatically scan images on push: Enabled
# Scanner une image manuellement via l'API Harbor
curl -X POST "https://registry.example.com/api/v2.0/projects/production/repositories/myapp/artifacts/1.0/scan"   -H "Authorization: Basic $(echo -n 'admin:password' | base64)"

# Récupérer les résultats
curl "https://registry.example.com/api/v2.0/projects/production/repositories/myapp/artifacts/1.0/additions/vulnerabilities"   -H "Authorization: Basic $(echo -n 'admin:password' | base64)"

Proxy cache Docker Hub : résoudre le rate limiting

# Créer un registry proxy dans Harbor
# Harbor → Registries → New Endpoint
# Provider: Docker Hub
# Endpoint URL: https://hub.docker.com

# Créer un projet proxy qui cache Docker Hub
# Harbor → Projects → New Project
# Name: docker-hub-cache
# Access Level: Public
# Registry: (votre endpoint Docker Hub)
# Proxy cache: Enabled
# Utiliser le proxy cache au lieu de Docker Hub directement
docker pull registry.example.com/docker-hub-cache/library/nginx:1.27
# Harbor télécharge depuis Docker Hub une fois et met en cache localement

Notre formation Docker couvre Harbor et la gestion des images en production.