harbor簡述


harbor1 192.168.10.10
harbor2 192.168.10.11

harbor作為私有倉庫被廣泛使用。harbor依賴docker和docker-compose,所以要先安裝docker和docker-compse。系統版本什么版本都可以

 

1安裝docker和docker-compose,自行安裝

2下載harbor,地址如下

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

此次下載的版本為1.8.2

3修改harbor配置(有的版本配置文件名是harbor.cfg)  hostname:可以是地址也可以是域名,域名自行解析,password:登錄harbor的密碼

 

 

 4啟動安裝腳本

 

 

 5.配置開機自啟腳本

[root@c1 harbor]# cat /usr/lib/systemd/system/harbor.service 
[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
Documentation=http://github.com/vmware/harbor

[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/bin/docker-compose -f /apps/harbor/docker-compose.yml up       自己的docker-compose.yml文件路徑
ExecStop=/usr/bin/docker-compose -f /apps/harbor/docker-compose.yml down

[Install]
WantedBy=multi-user.target
[root@c1 src]# systemctl enable --now harbor

6 啟動harbor

[root@c1 harbor]# docker-compose up

7修改docker啟動文件

[root@c1 src]# grep -Ev '^$|#' /usr/lib/systemd/system/docker.service 
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock  \
--insecure-registry 192.168.10.10 --insecure-registry 192.168.10.11 添加這兩個參數,否則無法登錄harbor,因為默認的是https
ExecReload=/bin/kill -s HUP $MAINPID TimeoutSec=0 RestartSec=2 Restart=always StartLimitBurst=3 StartLimitInterval=60s LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process [Install] WantedBy=multi-user.target

[root@c1 src]# systemctl daemon-reload && systemctl restart docker

8登錄harbor

[root@c1 src]# docker login 192.168.10.10
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

9登錄web頁面創建項目

 

 

 10上傳鏡像

[root@c1 harbor]# docker images |grep alpine
alpine                          latest                     961769676411        2 years ago         5.58MB
[root@c1 harbor]# docker tag alpine:latest 192.168.10.10/test1/alpine:latest          打tag,格式為harbor地址/項目名/鏡像名
[root@c1 harbor]# docker push 192.168.10.10/test1/alpine:latest          上傳鏡像,不能上傳執行docker login 192.168.10.10
The push refers to repository [192.168.10.10/test1/alpine]
03901b4a2ea8: Pushed 
latest: digest: sha256:acd3ca9941a85e8ed16515bfc5328e4e2f8c128caa72959a58a127b7801ee01f size: 528
[root@c1 harbor]# 


 

 

11 harbor高可用實現

在harbor2上同樣安裝docker,docker-compose,harbor,配置相同。不同點在於harbor的hostname為192.168.10.11。


harbor1配置如下

 

 

 

 

 

 

harbor2配置

 

 

 

 

 

 

 同步測試

harbor1上傳鏡像

[root@c1 ~]# docker tag nginx:1.14.2 192.168.10.10/test1/nginx:1.14.2
[root@c1 ~]# docker push 192.168.10.10/test1/nginx:1.14.2
The push refers to repository [192.168.10.10/test1/nginx]
82ae01d5004e: Pushed
b8f18c3b860b: Pushed
5dacd731af1b: Pushed
1.14.2: digest: sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078 size: 948
[root@c1 ~]#

harbor2也得到了nginx鏡像

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM