Installation et configuration de l'entrepôt miroir Harbor au niveau de l'entreprise

port

Aperçu du port

Harbor est un système de gestion d'entrepôt d'images de conteneurs open source doté de riches fonctions de sécurité et de gestion. Il peut créer des entrepôts privés dans des environnements d'entreprise et fournir des fonctionnalités telles que la fiabilité, la prise en charge multi-locataires et la personnalisation.

Site officiel:https://goharbor.io/

GitHub:https://github.com/goharbor/harbor

Harbor vise à fournir des solutions de gestion d'images au niveau de l'entreprise avec les caractéristiques et fonctions suivantes :

sécurité:

Harbor fournit un riche ensemble de fonctionnalités de sécurité, notamment l'authentification et l'autorisation des utilisateurs, la vérification des signatures d'image, le contrôle d'accès, l'analyse des vulnérabilités, etc. Cela vous aide à protéger vos images contre les attaques et les exploits malveillants.

Crédibilité:

Harbor prend en charge la signature numérique et la vérification des images pour garantir leur intégrité et leur origine fiable. Vous pouvez utiliser un certificat personnalisé ou tiers pour signer et vérifier l'authenticité de votre image.

Prise en charge multi-locataire :

Harbour prend en charge plusieurs projets et plusieurs entrepôts, qui peuvent être regroupés et gérés selon différentes organisations, équipes ou projets. Chaque projet peut avoir ses propres autorisations utilisateur et politiques de contrôle d'accès.

Personnalisation :

Harbor propose des options de configuration flexibles et des mécanismes d'extension qui peuvent être personnalisés en fonction de vos besoins. Vous pouvez ajuster les configurations telles que le stockage, la mise en réseau et l'authentification en fonction de différents environnements et besoins.

haute performance:

Harbour utilise des stratégies de mise en cache et de réplication pour améliorer la vitesse et la disponibilité d'accès aux images. Il prend en charge plusieurs backends de stockage miroir, notamment le stockage local, le stockage S3, etc.

Interface conviviale :

Harbor fournit une interface Web intuitive et facile à utiliser qui permet de gérer facilement les images, les projets, les utilisateurs, les autorisations d'accès, etc.

Installer le port

Téléchargez le fichier binaire Harbor pour l'installation. Référence d'installation et de configuration de Harbor :https://goharbor.io/docs/2.9.0/install-config/

Télécharger le package d'installation hors ligne

wget https://github.com/goharbor/harbor/releases/download/v2.7.3/harbor-offline-installer-v2.7.3.tgz

Décompressez le package d'installation

tar -zxvf harbor-offline-installer-v2.7.3.tgz
[root@master harbor]# ls
common.sh  harbor.v2.7.3.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare

Entrez dans l'annuaire du port

cd harbor

Configurer le port

cp harbor.yml.tmpl  harbor.yml

vim harbor.yml

# 当前节点主机名或IP
hostname: 112.74.96.150

# http端口配置
http:
  port: 8080

# 这里不使用https,注释该配置
#https:
  # https port for harbor, default is 443
#  port: 443
  # The path of cert and key files for nginx
#  certificate: /your/certificate/path
#  private_key: /your/private/key/path  

# Harbor UI的初始密码  
harbor_admin_password: Harbor12345

# The default data volume
data_volume: /usr/local/program/harbor/data

Exécutez le script d'installation

Après avoir configuré Harbour.yml, vous pouvez utiliser le script install.sh pour installer et démarrer Harbor.

./install.sh

Si l'installation réussit, le journal suivant sera affiché :

[Step 5]: starting Harbor ...
[+] Running 10/10
 ✔ Network harbor_harbor        Created                                                                                                                                                0.1s
 ✔ Container harbor-log         Started                                                                                                                                                0.1s
 ✔ Container registryctl        Started                                                                                                                                                0.2s
 ✔ Container harbor-db          Started                                                                                                                                                0.1s
 ✔ Container redis              Started                                                                                                                                                0.1s
 ✔ Container registry           Started                                                                                                                                                0.1s
 ✔ Container harbor-portal      Started                                                                                                                                                0.2s
 ✔ Container harbor-core        Started                                                                                                                                                0.1s
 ✔ Container harbor-jobservice  Started                                                                                                                                                0.1s
 ✔ Container nginx              Started                                                                                                                                                0.1s
✔ ----Harbor has been installed and started successfully.----

Affichez l'image du menu fixe et une liste d'images liées à hardor apparaîtra.


[root@master harbor]# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED              STATUS                        PORTS                       NAMES
62343618f630   goharbor/nginx-photon:v2.7.3         "nginx -g 'daemon of…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:8080->8080/tcp      nginx
a39ecd6eddf1   goharbor/harbor-jobservice:v2.7.3    "/harbor/entrypoint.…"   About a minute ago   Up About a minute (healthy)                               harbor-jobservice
f0c1a4957d04   goharbor/harbor-core:v2.7.3          "/harbor/entrypoint.…"   About a minute ago   Up About a minute (healthy)                               harbor-core
f64062148ccf   goharbor/harbor-registryctl:v2.7.3   "/home/harbor/start.…"   About a minute ago   Up About a minute (healthy)                               registryctl
6fc3d92cc65f   goharbor/harbor-db:v2.7.3            "/docker-entrypoint.…"   About a minute ago   Up About a minute (healthy)                               harbor-db
fc9917cad78e   goharbor/harbor-portal:v2.7.3        "nginx -g 'daemon of…"   About a minute ago   Up About a minute (healthy)                               harbor-portal
8622fab2670f   goharbor/registry-photon:v2.7.3      "/home/harbor/entryp…"   About a minute ago   Up About a minute (healthy)                               registry
27e3ba43f9f8   goharbor/redis-photon:v2.7.3         "redis-server /etc/r…"   About a minute ago   Up About a minute (healthy)                               redis
feef079dcbd4   goharbor/harbor-log:v2.7.3           "/bin/sh -c /usr/loc…"   About a minute ago   Up About a minute (healthy)   127.0.0.1:1514->10514/tcp   harbor-log

Se connecter

Accès au navigateur http://IP:8080
Insérer la description de l'image ici
Utilisez le nom d'utilisateur : admin, le mot de passe configuré : Harbor12345pour vous connecter
Insérer la description de l'image ici

Démarrage et arrêt du port

Arrêter le port

[root@master harbor]# docker-compose stop
[+] Running 9/9
 ⠿ Container harbor-jobservice  Stopped                                                                                                                                                0.0s
 ⠿ Container nginx              Stopped                                                                                                                                                0.0s
 ⠿ Container registryctl        Stopped                                                                                                                                               10.2s
 ⠿ Container harbor-portal      Stopped                                                                                                                                                0.3s
 ⠿ Container harbor-core        Stopped                                                                                                                                                0.0s
 ⠿ Container harbor-db          Stopped                                                                                                                                                0.4s
 ⠿ Container registry           Stopped                                                                                                                                                0.2s
 ⠿ Container redis              Stopped                                                                                                                                                0.5s
 ⠿ Container harbor-log         Stopped                                                                                                                                               10.2s

Port de départ

[root@master harbor]# docker-compose start
[+] Running 9/9
 ⠿ Container harbor-log         Started                                                                                                                                                0.3s
 ⠿ Container redis              Started                                                                                                                                                0.9s
 ⠿ Container registryctl        Started                                                                                                                                                0.7s
 ⠿ Container harbor-portal      Started                                                                                                                                                1.0s
 ⠿ Container harbor-db          Started                                                                                                                                                0.8s
 ⠿ Container registry           Started                                                                                                                                                1.0s
 ⠿ Container harbor-core        Started                                                                                                                                                0.3s
 ⠿ Container nginx              Started                                                                                                                                                0.5s
 ⠿ Container harbor-jobservice  Started 

Connectez-vous à l'entrepôt Harbour

Pour vous connecter au référentiel privé Harbour, exécutez la commande suivante pour vous connecter au référentiel Harbour :

docker login <Harbor仓库地址>

Exception de connexion

[root@master harbor]# docker login 112.74.96.150:8080
Username: admin
Password:
Error response from daemon: Get "https://112.74.96.150:8080/v2/": http: server gave HTTP response to HTTPS client

raison:

Par défaut, il communique avec l'entrepôt Harbour via le protocole HTTPS, mais l'entrepôt Harbor est uniquement configuré avec le service HTTP et n'active pas le service HTTPS.

solution

Première option :

Recherchez le répertoire où se trouve docker.service

[root@master harbor]# find / -name docker.service -type f
/usr/lib/systemd/system/docker.service

modifier vim /usr/lib/systemd/system/docker.service

Modifiez cette ligne de configuration :

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Utilisez --insecurel'option pour ignorer la vérification du certificat https, remplacez-la par ce qui suit :

ExecStart=/usr/bin/dockerd --insecure-registry 112.74.96.150:8080  -H fd:// --containerd=/run/containerd/containerd.sock

Option II :

Modifiez /etc/docker/daemon.jsonle fichier, ajoutez la configuration et spécifiez l'adresse IP de l'entrepôt miroir

{
    
    
	"insecure-registries": ["112.74.96.150"]
}

Se connecter

Recharger la configuration et redémarrer Docker

systemctl daemon-reload
systemctl restart docker

Connectez-vous à nouveau

Remarque : vous devrez peut-être redémarrer Harbor

[root@master harbor]# docker login 112.74.96.150:8080
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

quitter

Quitter le statut de connexion de l'entrepôt privé Harbour

docker logout <Harbor仓库地址>
[root@master ~]# docker login 112.74.96.150:8080
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

Pousser et tirer l'image du port

Convention de dénomination des images

Il existe certaines conventions de dénomination pour les noms d'images de Harbour. La différence est que le nom du projet doit être utilisé dans le nom de l'image. Pour plus de détails, reportez-vous aux exemples suivants.

Construire une image

docker build -t <Harbor仓库地址>/<项目名称>/<镜像名称>:<标签> .

Poussez l'image vers le référentiel Harbor

docker push <Harbor仓库地址>/<项目名称>/<镜像名称>:<标签>

Image du port de Pull

docker pull <Harbor仓库地址>/<项目名称>/<镜像名称>:<标签>

Créer un projet

Créez un projet dans l'interface du référentiel Harbour ou en utilisant l'API Harbor

Création d'interface
Insérer la description de l'image ici
Création d'API Harbour

curl -X POST -u username:password -H "Content-Type: application/json" -d '{
  "project_name": "projectname",
  "public": 1,
  "content_trust": "disabled"
}' https://<Harbor仓库地址>/api/projects

Pousser l'image

Extraire une image de test

[root@master ~]# docker pull testcontainers/helloworld

Voir cette image

[root@master ~]# docker images | grep hello
testcontainers/helloworld       latest       6974669be52b   2 years ago     12.7MB

Marquez l'image locale et placez-la dans l'entrepôt du port

Remarque : Un niveau supplémentaire est requis comme nom du projet.

[root@master harbor]# docker tag testcontainers/helloworld:latest 112.74.96.150:8080/projectname/helloworld:v1

Visualiser à nouveau l'image

[root@master harbor]# docker images | grep hello
112.74.96.150:8080/projectname/helloworld   v1           6974669be52b   2 years ago     12.7MB
testcontainers/helloworld                   latest       6974669be52b   2 years ago     12.7MB

Poussez l'image locale vers l'entrepôt miroir (vous devez d'abord vous connecter à l'entrepôt miroir)

[root@master harbor]# docker push  112.74.96.150:8080/projectname/helloworld:v1
The push refers to repository [112.74.96.150:8080/projectname/helloworld]
802cca11a560: Pushing [============================================>      ]  6.194MB/7.019MB
80b7fe966245: Pushed
50644c29ef5a: Pushing [=============================================>     ]  5.068MB/5.575MB

Connectez-vous à Harbor et vérifiez projectnamesous le nouveau projet. Une image a été poussée avec succès.

Insérer la description de l'image ici

Extraire l'image

Supprimer l'image existante

[root@master harbor]# docker images | grep hello
112.74.96.150:8080/projectname/helloworld   v1           6974669be52b   2 years ago     12.7MB
testcontainers/helloworld                   latest       6974669be52b   2 years ago     12.7MB

[root@master harbor]# docker rmi 112.74.96.150:8080/projectname/helloworld:v1
Untagged: 112.74.96.150:8080/projectname/helloworld:v1
Untagged: 112.74.96.150:8080/projectname/helloworld@sha256:4ee5a832ef6eee533df7224b80d4cceb9ab219599014f408d0b69690be94c396

[root@master harbor]# docker rmi testcontainers/helloworld:latest
Untagged: testcontainers/helloworld:latest
Untagged: testcontainers/helloworld@sha256:4ee5a832ef6eee533df7224b80d4cceb9ab219599014f408d0b69690be94c396

Extraire l'image de Harbour

[root@master harbor]# docker pull 112.74.96.150:8080/projectname/helloworld:v1
v1: Pulling from projectname/helloworld
df20fa9351a1: Downloading [==========>                                        ]  614.1kB/2.798MB
7d694ce25b07: Download complete
99f5116afda5: Downloading [================================>                  ]  
2.389MB/3.655MB

Afficher l'image extraite

[root@master harbor]# docker images | grep hell
112.74.96.150:8080/projectname/helloworld   v1           6974669be52b   2 years ago     12.7MB

Je suppose que tu aimes

Origine blog.csdn.net/qq_38628046/article/details/132848771
conseillé
Classement