Harbor是一個用於存儲和分發Docker鏡像的企業級Registry服務器,經過添加一些企業必需的功能特性,例如安全、標識和管理等,擴展了開源Docker Distribution。做爲一個企業級私有Registry服務器,Harbor提供了更好的性能和安全。提高用戶使用Registry構建和運行環境傳輸鏡像的效率。Harbor支持安裝在多個Registry節點的鏡像資源複製,鏡像所有保存在私有Registry中, 確保數據和知識產權在公司內部網絡中管控。另外,Harbor也提供了高級的安全特性,諸如用戶管理,訪問控制和活動審計等。node
這個軟件, 提供Docker鏡像的經常使用管理功能, 不像 docker registry 同樣,只能上傳、下載,無法查詢刪除,且它的版本近4年沒更新了。
Harbor下載網址:https://github.com/goharbor/harbor/releases
注意要下載離線版本,而不是在線版,除非你願意。linux
1. 開始安裝Harbor前,新增epel repo, 先安裝docker (1.13.x) , docker-compose (1.10.x),並啓動docker服務nginx
# yum-config-manager --add-repo http://mirrors.aliyun.com/epel/7/x86_64 # yum install docker docker-compose # systemctl enable docker && systemctl start docker
2. 下載並解壓離線安裝包,並進入其目錄。修改harbor.cfg配置文件hostname爲你須要的主機域名後,開始安裝(vmware把這腳本寫太好,各容器導入、配置、映射等都處理好了,傻瓜式體驗)git
# wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.5.3.tgz # tar zxpf harbor-offline-installer-v1.5.3.tgz # sed -i "s|reg.mydomain.com|YOUR.DNS.DOMAIN.NAME|g" harbor/harbor.cfg # sed -i "s|Harbor12345|YourWebUIadminPassword|g" harbor/harbor.cfg
3. 建立ssl證書,並更新配置文件github
# mkdir -p /data/cert # openssl req -x509 -nodes -newkey rsa:4096 -sha256 -days 999 \ -keyout /data/cert/ispcdocker.com.key \ -out /data/cert/ispcdocker.com.crt \ -subj "/C=CN/ST=docker/L=wuhan/O=ispc/OU=New site/CN=ispcdocker.com/emailAddress=macj@ispcdocker.com" # sed -i "s|server.crt|ispcdocker.com.crt|g" harbor/harbor.cfg # sed -i "s|server.key|ispcdocker.com.key|g" harbor/harbor.cfg # sed -i "s|ui_url_protocol = http|ui_url_protocol = https|g" harbor/harbor.cfg
docker 客戶端服務器,需新增目錄/etc/docker/certs.d/ispcdocker.com,並放入證書文件 ispcdocker.com.crt
4. 開始安裝
# ./harbor/install.sh redis
[Step 0]: checking installation environment ... Note: docker version: 1.13.1 Note: docker-compose version: 1.18.0 [Step 1]: loading Harbor images ... dba693fc2701: Loading layer [==================================================>] 133.4 MB/133.4 MB 2a5686d9628d: Loading layer [==================================================>] 30.09 MB/30.09 MB d36839094404: Loading layer [==================================================>] 12.16 MB/12.16 MB d7d603a1fc1b: Loading layer [==================================================>] 17.3 MB/17.3 MB 0f4a9a0efd40: Loading layer [==================================================>] 15.87 kB/15.87 kB c3f3baab14ec: Loading layer [==================================================>] 3.072 kB/3.072 kB 7dfec12d33a9: Loading layer [==================================================>] 29.46 MB/29.46 MB Loaded image: vmware/notary-server-photon:v0.5.1-v1.5.3 d4718453703e: Loading layer [==================================================>] 165.3 MB/165.3 MB d1ce74e3e78b: Loading layer [==================================================>] 10.93 MB/10.93 MB ac11a823a541: Loading layer [==================================================>] 2.048 kB/2.048 kB f998dbfce255: Loading layer [==================================================>] 48.13 kB/48.13 kB 236d02b5f213: Loading layer [==================================================>] 10.97 MB/10.97 MB Loaded image: vmware/clair-photon:v2.0.5-v1.5.3 a5c06f1276a9: Loading layer [==================================================>] 410 MB/410 MB 8cb6e0c2cee6: Loading layer [==================================================>] 9.216 kB/9.216 kB e5242ff0e21c: Loading layer [==================================================>] 9.216 kB/9.216 kB 565919f93038: Loading layer [==================================================>] 7.68 kB/7.68 kB c59fe8aadc39: Loading layer [==================================================>] 1.536 kB/1.536 kB 9d5156272f97: Loading layer [==================================================>] 11.78 kB/11.78 kB 82107159e9cf: Loading layer [==================================================>] 2.56 kB/2.56 kB 45f5d9c065c0: Loading layer [==================================================>] 3.072 kB/3.072 kB Loaded image: vmware/harbor-db:v1.5.3 8c31ce3b9459: Loading layer [==================================================>] 89.33 MB/89.33 MB 318b6651319e: Loading layer [==================================================>] 3.072 kB/3.072 kB c839c1286b82: Loading layer [==================================================>] 59.9 kB/59.9 kB 7d474fe49011: Loading layer [==================================================>] 61.95 kB/61.95 kB Loaded image: vmware/redis-photon:v1.5.3 be289099e564: Loading layer [==================================================>] 11.97 MB/11.97 MB Loaded image: vmware/nginx-photon:v1.5.3 b4b466185e6a: Loading layer [==================================================>] 30.09 MB/30.09 MB 0cc49b6cc09c: Loading layer [==================================================>] 20.91 MB/20.91 MB 51763c526b85: Loading layer [==================================================>] 20.91 MB/20.91 MB Loaded image: vmware/harbor-jobservice:v1.5.3 78ee9810b0f6: Loading layer [==================================================>] 102.5 MB/102.5 MB 7ad0f67912f5: Loading layer [==================================================>] 6.656 kB/6.656 kB 742c91b5588b: Loading layer [==================================================>] 2.048 kB/2.048 kB 0f6bb290e555: Loading layer [==================================================>] 7.68 kB/7.68 kB Loaded image: vmware/postgresql-photon:v1.5.3 454c81edbd3b: Loading layer [==================================================>] 135.2 MB/135.2 MB e99db1275091: Loading layer [==================================================>] 395.4 MB/395.4 MB 051e4ee23882: Loading layer [==================================================>] 9.216 kB/9.216 kB 6cca4437b6f6: Loading layer [==================================================>] 9.216 kB/9.216 kB 1d48fc08c8bc: Loading layer [==================================================>] 7.68 kB/7.68 kB 0419724fd942: Loading layer [==================================================>] 1.536 kB/1.536 kB 543c0c1ee18d: Loading layer [==================================================>] 655.2 MB/655.2 MB 4190aa7e89b8: Loading layer [==================================================>] 103.9 kB/103.9 kB Loaded image: vmware/harbor-migrator:v1.5.0 Loaded image: photon:1.0 1cb3e179ad43: Loading layer [==================================================>] 10.95 MB/10.95 MB fc6a61e18876: Loading layer [==================================================>] 17.3 MB/17.3 MB 9a0e4d2eebcc: Loading layer [==================================================>] 15.87 kB/15.87 kB db1781274784: Loading layer [==================================================>] 3.072 kB/3.072 kB 8f838ad4a4a8: Loading layer [==================================================>] 28.24 MB/28.24 MB Loaded image: vmware/notary-signer-photon:v0.5.1-v1.5.3 Loaded image: vmware/mariadb-photon:v1.5.3 18726298d495: Loading layer [==================================================>] 30.09 MB/30.09 MB b9ed103273e7: Loading layer [==================================================>] 2.56 kB/2.56 kB c70c3ca2b37a: Loading layer [==================================================>] 2.56 kB/2.56 kB adff27057ad4: Loading layer [==================================================>] 2.048 kB/2.048 kB f6616ceb4679: Loading layer [==================================================>] 22.8 MB/22.8 MB bc864fbf8cf5: Loading layer [==================================================>] 22.8 MB/22.8 MB Loaded image: vmware/registry-photon:v2.6.2-v1.5.3 7d62cd6592f6: Loading layer [==================================================>] 30.09 MB/30.09 MB 86b34d4705c7: Loading layer [==================================================>] 15.37 MB/15.37 MB c39dac15ee95: Loading layer [==================================================>] 15.37 MB/15.37 MB Loaded image: vmware/harbor-adminserver:v1.5.3 8b4d494f800d: Loading layer [==================================================>] 30.09 MB/30.09 MB c2125811685a: Loading layer [==================================================>] 24.41 MB/24.41 MB 8d81b9f3593b: Loading layer [==================================================>] 7.168 kB/7.168 kB 027ed79fa3f9: Loading layer [==================================================>] 10.56 MB/10.56 MB e293dcd69589: Loading layer [==================================================>] 24.4 MB/24.4 MB Loaded image: vmware/harbor-ui:v1.5.3 c8de2c0f8a35: Loading layer [==================================================>] 79.91 MB/79.91 MB 95e6a55db9bc: Loading layer [==================================================>] 3.584 kB/3.584 kB eec0ff35e410: Loading layer [==================================================>] 3.072 kB/3.072 kB 6db6ff46ce4a: Loading layer [==================================================>] 4.096 kB/4.096 kB 6f2de56be0b2: Loading layer [==================================================>] 3.584 kB/3.584 kB 7f4232890807: Loading layer [==================================================>] 9.728 kB/9.728 kB Loaded image: vmware/harbor-log:v1.5.3 [Step 2]: preparing environment ... Generated and saved secret to file: /data/secretkey Generated configuration file: ./common/config/nginx/nginx.conf Generated configuration file: ./common/config/adminserver/env Generated configuration file: ./common/config/ui/env Generated configuration file: ./common/config/registry/config.yml Generated configuration file: ./common/config/db/env Generated configuration file: ./common/config/jobservice/env Generated configuration file: ./common/config/jobservice/config.yml Generated configuration file: ./common/config/log/logrotate.conf Generated configuration file: ./common/config/jobservice/config.yml Generated configuration file: ./common/config/ui/app.conf Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt The configuration files are ready, please use docker-compose to start the service. Creating harbor-log ... done [Step 3]: checking existing instance of Harbor ... Creating redis ... done Creating harbor-ui ... done Creating network "harbor_harbor" with the default driver Creating nginx ... done Creating redis ... Creating registry ... Creating harbor-db ... Creating harbor-adminserver ... Creating harbor-ui ... Creating harbor-jobservice ... Creating nginx ... ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at https://ispcdocker.com. For more details, please visit https://github.com/vmware/harbor .
5. 若是配置文件打算修改,並從新安裝, 可用下面方式簡單處理
# docker-compose down ## 第一步中止harbor
# vim harbor.cfg ## 修改鏡像
# install.sh ## 從新初始化鏡像sql
6. 重啓harbor
# docker-compose stop
# docker-compose up -d docker
6. 登陸默認的密碼是 admin/Harbor12345 ,此密碼在壓縮包內的harbor.cfg配置文件中設定。vim
7. 用戶指南
https://github.com/goharbor/harbor/blob/master/docs/user_guide.md
此軟件的開源版本,僅提供docker鏡像的各管理功能,無其餘。 且有中文界面可供選擇,操做很容易api
8. docker 客戶端服務器,需將新增目錄/etc/docker/certs.d/ispcdocker.com,並放入前面步驟建立的證書文件ispcdocker.com.crt (拷貝、下載、粘貼複製方法不限,整過去就行)
# wget -P /etc/docker/certs.d/ispcdocker.com http://10.245.254.93/linux/soft/docker/ispcdocker.com.crt #(use for docker client before pull image) # docker login --username=admin ispcdocker.com # docker tag SOURCE_IMAGE[:TAG] ispcdocker.com/library/IMAGE[:TAG] # docker push ispcdocker.com/library/IMAGE[:TAG]