相對(duì)于采用公共的鏡像倉庫约素,使用私有鏡像倉庫洽故,可以部署在內(nèi)網(wǎng)中贝攒,利用內(nèi)網(wǎng)的安全防護(hù)如防火墻等,更安全更高效时甚,方便內(nèi)部控制隘弊。
Harbor 是一個(gè)企業(yè)級(jí)可以應(yīng)用于生產(chǎn)環(huán)境的鏡像倉庫。Harbor 是由VMware的中國(guó)區(qū)研發(fā)中心創(chuàng)建的荒适,主力開發(fā)都是中國(guó)人梨熙,很多國(guó)內(nèi)公司都在使用。
優(yōu)點(diǎn)
高效的docker文件分層傳輸刀诬,提供高效的鏡像上傳下載
提供鏡像安全性掃描咽扇,漏洞掃描功能
提供易于操作的用戶web界面
企業(yè)級(jí)的安全認(rèn)證方式(多種)
主力開發(fā)人員是中國(guó)人,方便交流
安裝
安裝很簡(jiǎn)單,可以參考官方文檔肌割,這里就不在敘述了
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
與Drone CI 集成
通過Harbor界面創(chuàng)建一個(gè)test名字的項(xiàng)目卧蜓,tag想要上傳的鏡像,然后push鏡像:
docker tag hello-world xx.xx.xx.xx:5000/test/hello-world
docker push xx.xx.xx.xx:5000/test/hello-world
drone.yml
kind: pipeline
name: default
steps:
- name: build
image: xxxxxxx:5000/test/hello-world
commands:
- bundle
image_pull_secrets:
- dockerconfigjson
通過drone web ui 界面添加 Secrets
name: dockerconfigjson
value:
{
"auths": {
"xxxx.com:5000": {
"auth": "YWRtaW46SGFyYm9yMTIzNDU="
}
}
}
auth 文件里內(nèi)容實(shí)際是用戶名密碼串簡(jiǎn)單的base64形式把敞,可以簡(jiǎn)單的通過l類似下邊的命令獲取弥奸。
echo -n 'admin:Harbor12345' | base64
YWRtaW46SGFyYm9yMTIzNDU=
(例子中用戶名密碼是Harbor默認(rèn)值)
當(dāng)Harbor沒有配置ssh,drone主機(jī)上docker需要配置insecure-registries奋早,
在/etc/docker/daemon.json文件中增加下列內(nèi)容
{
"insecure-registries": ["xxx.com:5000"]
}
(mac下需要在ui界面中設(shè)置)
如果你的當(dāng)Harbor沒有配置ssh盛霎,用plugins/docker插件一定要記得設(shè)置insecure: true
steps:
- name: docker
image: plugins/docker
settings:
registry: xxxx
repo: xxxx:5000/test/hello-world
username: admin
password: Harbor12345
insecure: true
debug: true
想要了解registry基本原理可以從drone與那代碼中的測(cè)試文件
plugin/registry/static_test.go入手
公眾號(hào)
王司技術(shù)談