使用 Harbor 建立 Docker 私有儲存庫(Docker Registry) 安裝示範

Harbor 是一個免費開源、可商用的 Docker 儲存庫(Docker Registry),具有圖形化介面,比官方的 Docker Registry 更好操作。

*在開始前需要先安裝完 Docker *

harbor 的 GitHub 發佈頁面下載最新版本的安裝檔,有需要連線的安裝檔和離線安裝檔,這裡使用連線安裝檔做示範。範例版本為 v2.11.2
    
wget https://github.com/goharbor/harbor/releases/download/v2.11.2/harbor-online-installer-v2.11.2.tgz
    

將下載的檔案解壓縮:
    
tar xzvf harbor-online-installer-v2.11.2.tgz
    

解壓縮後會產生 harbor 資料夾,我們把他移動到 linux 中專門存放第三方軟體的 /opt 路徑
    
sudo mv harbor /opt/
    

進入到剛剛移動完畢的新路徑下:
    
cd /opt/harbor/
    

原本資料夾內就有附設定檔範本檔: harbor.yml.tmpl ,我們把他複製一份,取名為 harbor.yml
    
cp harbor.yml.tmpl harbor.yml
    

編輯設定檔:
    
vi harbor.yml
    

需要調整 hostname ,改成網域名稱或 IP
目前暫時不使用 https ,將以下 https 相關內容註解
harbor_admin_password 則是 admin 帳號的預設密碼:
    
hostname: reg.mydomain.com

http:
  port: 80

# https related config
https:
  port: 443
  certificate: /your/certificate/path
  private_key: /your/private/key/path
  
harbor_admin_password: Harbor12345
    

調整後的樣子:
    
hostname: 192.168.0.40

http:
  port: 80

# https related config
#https:
  #port: 443
  #certificate: /your/certificate/path
  #private_key: /your/private/key/path
  
harbor_admin_password: Harbor12345
    

執行安裝:
    
sudo ./install.sh
    

安裝完成後會出現:
    
sudo ./install.sh
[+] Running 10/10
 ✔ Network harbor_harbor        Created   0.2s
 ✔ Container harbor-log         Started   2.0s
 ✔ Container registry           Started   1.4s
 ✔ Container registryctl        Started   1.3s
 ✔ Container redis              Started   1.4s
 ✔ Container harbor-db          Started   1.3s
 ✔ Container harbor-portal      Started   1.4s
 ✔ Container harbor-core        Started   1.7s
 ✔ Container harbor-jobservice  Started   2.2s
 ✔ Container nginx              Started   2.2s
✔ ----Harbor has been installed and started successfully.----
    

使用 docker ps 會發現有非常多容器在執行
    
docker ps
CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS                    PORTS                                     NAMES
b10eb72e8a3f   goharbor/harbor-jobservice:v2.11.2    "/harbor/entrypoint.…"   23 minutes ago   Up 23 minutes (healthy)                                             harbor-jobservice
f1d43a3e9fea   goharbor/nginx-photon:v2.11.2         "nginx -g 'daemon of…"   23 minutes ago   Up 23 minutes (healthy)   0.0.0.0:80->8080/tcp, [::]:80->8080/tcp   nginx
4649e5e1b5f7   goharbor/harbor-core:v2.11.2          "/harbor/entrypoint.…"   23 minutes ago   Up 23 minutes (healthy)                                             harbor-core
c32a74558a13   goharbor/harbor-db:v2.11.2            "/docker-entrypoint.…"   23 minutes ago   Up 23 minutes (healthy)                                             harbor-db
f3e5afd40784   goharbor/redis-photon:v2.11.2         "redis-server /etc/r…"   23 minutes ago   Up 23 minutes (healthy)                                             redis
63bf47bd7633   goharbor/harbor-portal:v2.11.2        "nginx -g 'daemon of…"   23 minutes ago   Up 23 minutes (healthy)                                             harbor-portal
263ca02cbceb   goharbor/registry-photon:v2.11.2      "/home/harbor/entryp…"   23 minutes ago   Up 23 minutes (healthy)                                             registry
20f051978c63   goharbor/harbor-registryctl:v2.11.2   "/home/harbor/start.…"   23 minutes ago   Up 23 minutes (healthy)                                             registryctl
e7907a501262   goharbor/harbor-log:v2.11.2           "/bin/sh -c /usr/loc…"   23 minutes ago   Up 23 minutes (healthy)   127.0.0.1:1514->10514/tcp                 harbor-log
    

在網址中輸入剛剛設定的 hostname 就可以連線到 Harbor (筆者的是 192.168.0.40):

預設帳號:admin
預設密碼:Harbor12345 (如果剛剛在設定檔中有修改就是使用設定檔中的密碼)

參考資料:
Harbor

留言