harbor官方文檔
環境說明
主機 | IP |
---|---|
docker | 192.168.20.135 |
安裝harbor
1.安裝docker-compose
[root@docker ~]# yum -y install docker-compose
2.將壓縮包解壓
[root@docker ~]# cd /usr/src/ [root@docker ~]# wget https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz
[root@docker ~]# tar xf harbor-offline-installer-v2.0.2.tgz -C /usr/local/ [root@docker ~]# cd /usr/local/harbor [root@docker harbor]# ls common.sh harbor.yml.tmpl LICENSE harbor.v2.0.2.tar.gz install.sh prepare
3.復制harbor.yml.tmpl文件為harbor.yml
[root@docker harbor]# cp harbor.yml.tmpl harbor.yml
4.修改配置文件
//改為本機IP
hostname: 192.168.20.135
//沒有配置ssl證書就注釋掉
# https related config #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 //用戶名admin,密碼Harbor12345
# The initial password of Harbor admin # It only works in first time to install harbor # Remember Change the admin password from UI after launching Harbor. harbor_admin_password: Harbor12345
啟動
[root@docker harbor]# systemctl start docker [root@docker harbor]# ./install.sh ✔ ----Harbor has been installed and started successfully.---- [root@docker harbor]# [root@docker harbor]# [root@docker harbor]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:1514 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::*
使用Harbor
登入
我們可以看到系統各個模塊如下:
項目:新增/刪除項目,查看鏡像倉庫,給項目添加成員、查看操作日志、復制項目等
日志:倉庫各個鏡像create、push、pull等操作日志
系統管理
- 用戶管理:新增/刪除用戶、設置管理員等
- 倉庫管理:新增/刪除從庫目標、新建/刪除/啟停復制規則等
- 復制管理:認證模式、復制、郵箱設置、系統設置等
- 標簽添加到本項目的鏡像中。
- 全局級別標簽:由系統管理員管理,用於管理整個系統的鏡像。它 們可以添加到任何項目下的鏡像中。
- 項目級別標簽:由項目管理員或者系統管理員在項目下管理,只能
- 項目定額:分配每個項目多少存儲空間
- 審查服務:掃描漏銅
- 垃圾清理:清理不需要的鏡像
- 配置管理:認證設置、郵箱設置、系統設置
注意:非系統管理員用戶登錄,只能看到有權限的項目和日志,其他模塊不可見。
登錄傳鏡像了
我們需要在/etc/docker/daemon.json加上 “insecure-registries”:[“harborIP”]
[root@docker ~]# vim /etc/docker/daemon.json [root@docker ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://0v0l236l.mirror.aliyuncs.com"], "insecure-registries":["192.168.20.135"] } //重啟服務
[root@docker harbor]# systemctl restart docker //登入
[root@docker harbor]# docker login 192.168.20.135 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 //改標簽
[root@docker ~]# docker tag nginx:latest 192.168.20.135/nginx/nginx:v0.1 [root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.20.135/nginx/nginx v0.1 4bb46517cac3 2 weeks ago 133MB nginx latest 4bb46517cac3 2 weeks ago 133MB
//上傳鏡像到harbor倉庫
[root@docker ~]# docker push 192.168.20.135/nginx/nginx:v0.1 The push refers to repository [192.168.20.135/nginx/nginx] 550333325e31: Pushed 22ea89b1a816: Pushed a4d893caa5c9: Pushed 0338db614b95: Pushed d0f104dc0a1f: Pushed v0.1: digest: sha256:179412c42fe3336e7cdc253ad4a2e03d32f50e3037a860cf5edbeb1aaddb915c size: 1362
創建用戶,分配權限
添加到nginx項目中,並設置權限
[root@localhost ~]# vim /etc/docker/daemon.json { "registry-mirrors": ["https://0v0l236l.mirror.aliyuncs.com"], "insecure-registries":["192.168.20.135"] } [root@localhost ~]# systemctl restart docker
登錄
[root@localhost ~]# docker login 192.168.20.135 Username: zzl 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
上傳鏡像
[root@localhost ~]# docker tag nginx:latest 192.168.20.135/nginx/nginx:v0.2 [root@localhost ~]# docker push 192.168.20.135/nginx/nginx:v0.2 The push refers to repository [192.168.20.135/nginx/nginx] 550333325e31: Layer already exists 22ea89b1a816: Layer already exists a4d893caa5c9: Layer already exists 0338db614b95: Layer already exists d0f104dc0a1f: Layer already exists v0.2: digest: sha256:179412c42fe3336e7cdc253ad4a2e03d32f50e3037a860cf5edbeb1aaddb915c size: 1362
Docker 鏡像復制
harbor | IP |
---|---|
docker | 192.168.20.135/24 |
harbor002 | 192.168.20.99/24 |
在倉庫管理,新建一個目標
同步
在192.168.20.99上查看,同步完成