close

系統:CentOS 7.4    套件:Vmware harbor

 


安裝harbor

# vim /etc/yum.repos.d/docker.repo

新增

=!===

[dockerrepo]

name=Docker Repository

baseurl=https://yum.dockerproject.org/repo/main/centos/7/

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

===!=

 

安裝 docker-engine

#yum install docker-engine

 

啟動

#systemctl enable docker

#systemctl start docker

 


安裝docker-compose

# sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

 

賦予執行權限

#chmod +x /usr/local/bin/docker-compose

測試一下能否執行

#docker-compose --version

 


開始安裝harbor

Harbor Vmware提供的套件

# wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.1.tgz

# tar -zxvf harbor-offline-installer-v1.5.1.tgz

 

接著要切換進harbor資料夾,修改設定

# cd harbor

# vim harbor.cfg

 

調整hostname設定,對應網域or IP位址

 

密碼預設是:Harbor12345

預設驗證方式是使用資料庫驗證(db_auth)

當然也支援LDAP驗證方法

 

是否開啟註冊功能&Token預設有效時間是多久

 

建立專案的許可,可以讓誰來建立專案。

(everyone = 所有人)

(adminonly = 只有管理員)

 

資料庫預設帳號密碼 (root / root123)

(也可以依照自己需求修改)

 

基本上確認及依照環境修改設定檔,就可以開始進行安裝。

這邊我們只修改hostname,其它部分讓它照預設值運行看看

 


接著開始進行安裝。

這邊安裝是透過docker-compose進行。

(這也是為什麼我們要先裝docker-compose的原因)

#./install.sh

發生錯誤訊息

Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.

 

Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.cfg bacause notary must run under https.

 

Please set --with-clair if needs enable Clair in Harbor

 

這邊試了幾邊都有一樣的問題,後來發現是V1.5的設定檔當下好像有狀況。

降成V1.4版本後,安裝動作都正常。

設定檔部分都是大同小異。

#wget https://storage.googleapis.com/harbor-releases/release-1.4.0/harbor-offline-installer-v1.4.0.tgz

#tar -zxvf harbor-offline-installer-v1.4.0.tgz

#cd harbor

#vim harbor.cfg (修改設定檔,hostname是比較重要的數值)

#./install.sh

 

運作到這邊就算是完成了。

 

因為這邊是私自建立的Docker Registry

所以老樣子,要添加--insecure-registry

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

=!===

ExecStart=/usr/bin/dockerd --insecure-registry 172.16.130.136

===!=

 

設定完後記得重啟Docker Service

#systemctl daemon-reload

#systemctl restart docker

 

檢查一下本機docker環境,可以看到建立了許多Docker Container

 

在瀏覽器輸入剛剛設定的Hostname名稱(網址 IP)

http://harbortest.test.com

就可以看到下方Docker Registry的環境。

 

 

 

使用admin帳號配合在harbor.cfg內修改過後的密碼進行登入。

( admin / Harbor12345<預設>)

 

就可以登入內部環境

 

除了英文版本外,還有簡體中文可以查看。

 

接著試著用docker command 登入並推上docker image 測試看看。

# docker login [網域名稱 or IP]

這邊登入的帳密就是登入WEB頁面的帳密

(admin / Harbor12345)

 

接著我們可以試著向上推撥Docker image測試看看。

先下載一個ubuntu docker image

# docker pull ubuntu

 

檢查一下目前本機上的Docker Image有哪些

#docker image list

除了ubuntu 外,其他都是vmware harbor抓下來的docker image

 

ubuntu docker image打上tag

(基本上要上傳到哪去,TAG最前面要帶上目標端的IP or 網址)

#docker tag ubuntu:latest 172.16.130.136/library/ubuntu:latest

這邊的階級要注意,如果要使用harbor,預設都要帶上網library路徑才行。

不然上傳會一直無效。(這邊用兩個模式來測試)

 

#docker push 172.16.130.136/library/ubuntu

(正確的模式)

 

#docker push 172.16.130.136/ubuntu

(因路徑上有問題,會不斷地Retry到失敗為止)

這邊要上傳到Vmware harbor時要特別注意。

 

回到WEB頁面查看library後,

可以看到剛剛上傳的ubuntu docker image

 

當然不想用library這個名稱也可以,

假設要使用 test 這個名稱

 

先設定成公開用來測試,

平常是不要打開,要使用docker login驗證後再抓取才正確。

 

這邊可以看到建立完成。

 

這次pull CentOS docker image 回來上傳測試看看

#docker pull centos

#docker tag centos 172.16.130.136/test/centos

# docker push  172.16.130.136/test/centos

可以看到可以正確的上傳

 

再回到WEB端檢查一下。

可以看到centos已經被傳送上來。

 

登出後回到首頁,也可以看到剛剛發佈上來的Docker Image

 

透過vmware harbor 圖形化介面操作,會比docker Registry好上手許多。

介面上還有部分方便的功能,再請大家自行發掘。

 


<本篇完>

參考網址:

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

https://itw01.com/GYFJEZA.html

https://github.com/vmware/harbor/blob/master/docs/installation_guide.md

https://www.ilanni.com/?p=13492

arrow
arrow
    全站熱搜

    IT001 發表在 痞客邦 留言(0) 人氣()