1.安裝harbor
參考[部落格](https://www.cnblogs.com/huangjc/p/6266564.html)
1、下載所需的軟體包(以下需要-翻-牆-下載的地方你們自己解決吧......):
(1)下載docker-compose:
curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
(2)下載harbor:
wget https://github.com/vmware/harbor/releases/download/0.5.0/harbor-offline-installer-0.5.0.tgz
#我下載的是offline離線包,這樣在後續的部署及安裝都會比較快,總共有300M左右的大小!
(3)解壓,配置harbor:
tar zxvf harbor-offline-installer-0.5.0.tgz
cd harbor/
#vim harbor.cfg
hostname = 192.168.6.113
#這裡只是簡單的測試,所以只編輯這一行,其他的預設不做修改;當然也可以根據你自己的實際情況做修改!
(4)執行安裝指令碼:
#會拉取好幾個映象下來,及檢查環境:
#./instsll.sh
Note: docker version: 1.12.5
Note: docker-compose version: 1.9.0
[Step 0]: checking installation environment ...
....
[Step 1]: loading Harbor images ...
....
[Step 2]: preparing environment ...
....
[Step 3]: checking existing instance of Harbor ...
....
[Step 4]: starting Harbor ...
....
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.6.113.
For more details, please visit https://github.com/vmware/harbor .
複製程式碼
安裝完成後會生成如下6個容器:
複製程式碼
Harbor容器的stop與start:
進入Harbor目錄執行如下命令即可:
docker-compose stop/start
複製程式碼
到此便安裝完成了,直接開啟瀏覽器登陸即可:
預設使用者密碼是:admin/Harbor12345
複製程式碼
建議使用更新的1.5版本
操作指南參考:
測試登入遠端映象倉庫
docker login ip / domain(有問題未解決)
上傳映象
先要標記映象
REPOSITOR:TAG harborDomain/專案名稱/映象名:標籤
docker tag alpine:latest 192.168.242.132/library/alpine:latest
然後推送映象
docker push 192.168.242.132/library/alpine:latest
從Harbor映象倉庫拉取映象到客戶端
先將客戶端的已有映象刪除
docker rmi 11cd0b38bc3c
然後使用命令拉取映象
docker pull 192.168.242.132/library/alpine:latest
最後檢視映象,拉取成功。
docker images
複製程式碼
問題及解決
登入到遠端映象倉庫(用ip)
Error response from daemon: Get https://172.20.48.93/v2/:
dial tcp 172.20.48.93:443: getsockopt: connection refused
解決方法:
1.修改docker配置檔案
sudo vim /etc/default/docker
新增DOCKER_OPTS="--insecure-registry 172.20.48.93"
2.重啟docker
sudo service docker restart
3.重新登入
docker login ip
4.上傳下拉映象
docker push ip/專案名/映象名:標籤
複製程式碼
待解決,用域名還是會報錯
Error response from daemon: Get https://harbor.local.com/v2/:
dial tcp 172.20.48.93:443: getsockopt: connection refused複製程式碼