Harbor不仅是一款功能完善、开源免费的Docker镜像仓库,而且还自带了镜像文件的安全扫描器,可以扫描出基础镜像存在的安全组件漏洞。在搭建个人或者企业内部的私有云时,harbor绝对是搭建私有仓库的首选。Harbor 2.1.3版本是兼容Docker最新的20.10.x的版本。第一步,生成密(私)钥(
第二步,配置harbor.yml
# vi harbor.yml
# Configuration file of Harbor
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.1xx.xxx.xxx
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
# https related config
https:
# https port for harbor, default is 443
port: 443
# The path of cert and key files for nginx
certificate: /root/cert/Your-DomainName.crt
private_key: /root/cert/Your-DomainName.key
第三步,安装Harbor
# ./install.sh --with-trivy --with-clair --with-notary --with-chartmuseum
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.2
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.27.4
[Step 2]: loading Harbor images ...
72021dc640d8: Loading layer [==================================================>] 34.51MB/34.51MB
ac18f6a923ed: Loading layer [==================================================>] 6.237MB/6.237MB
443e718caf06: Loading layer [==================================================>] 4.096kB/4.096kB
151d94acadb3: Loading layer [==================================================>] 3.072kB/3.072kB
a4b49bb1e114: Loading layer [==================================================>] 23.51MB/23.51MB
c78521954d03: Loading layer [==================================================>] 13.03MB/13.03MB
0c47889bec53: Loading layer [==================================================>] 37.36MB/37.36MB
Loaded image: goharbor/trivy-adapter-photon:v2.1.3
03d035e6fdd6: Loading layer [==================================================>] 77.47MB/77.47MB
17378e897238: Loading layer [==================================================>] 56.14MB/56.14MB
37e0db793f9a: Loading layer [==================================================>] 2.56kB/2.56kB
f2b1c8e30fee: Loading layer [==================================================>] 1.536kB/1.536kB
9bdf41331535: Loading layer [==================================================>] 18.43kB/18.43kB
ba870a8f8b07: Loading layer [==================================================>] 4.044MB/4.044MB
c9c3cbc34878: Loading layer [==================================================>] 266.2kB/266.2kB
Loaded image: goharbor/prepare:v2.1.3
63466623017f: Loading layer [==================================================>] 74.89MB/74.89MB
df442b800e1e: Loading layer [==================================================>] 3.584kB/3.584kB
452e97ba3502: Loading layer [==================================================>] 3.072kB/3.072kB
c471bd98cbb5: Loading layer [==================================================>] 2.56kB/2.56kB
17fddea06fe1: Loading layer [==================================================>] 3.072kB/3.072kB
475fc394c201: Loading layer [==================================================>] 3.584kB/3.584kB
933a98d9fbe2: Loading layer [==================================================>] 12.29kB/12.29kB
a763d912993b: Loading layer [==================================================>] 3.584kB/3.584kB
Loaded image: goharbor/harbor-log:v2.1.3
c4362766d017: Loading layer [==================================================>] 35.94MB/35.94MB
2a17b1bfc06e: Loading layer [==================================================>] 3.072kB/3.072kB
18f95416e6ca: Loading layer [==================================================>] 59.9kB/59.9kB
66e00c38ca7a: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.1.3
e7ecd452926a: Loading layer [==================================================>] 6.779MB/6.779MB
Loaded image: goharbor/nginx-photon:v2.1.3
b297dbe84e45: Loading layer [==================================================>] 4.926MB/4.926MB
740cb9327cf8: Loading layer [==================================================>] 6.364MB/6.364MB
702e21d9a02a: Loading layer [==================================================>] 14.45MB/14.45MB
41bf73d5edf7: Loading layer [==================================================>] 27.98MB/27.98MB
380c69145954: Loading layer [==================================================>] 22.02kB/22.02kB
8e8d77f973be: Loading layer [==================================================>] 14.45MB/14.45MB
Loaded image: goharbor/notary-signer-photon:v2.1.3
1e8793fa6411: Loading layer [==================================================>] 111.8MB/111.8MB
46f05a34c35a: Loading layer [==================================================>] 12.6MB/12.6MB
2b4935d92967: Loading layer [==================================================>] 3.072kB/3.072kB
53d92caec796: Loading layer [==================================================>] 49.15kB/49.15kB
755503f08c76: Loading layer [==================================================>] 4.096kB/4.096kB
47f4a1c04d3e: Loading layer [==================================================>] 13.47MB/13.47MB
Loaded image: goharbor/clair-photon:v2.1.3
5b519183d61a: Loading layer [==================================================>] 6.779MB/6.779MB
495ec8d8cbc6: Loading layer [==================================================>] 8.993MB/8.993MB
63afd0d6ec10: Loading layer [==================================================>] 173.6kB/173.6kB
09ec33f4b9b5: Loading layer [==================================================>] 152.6kB/152.6kB
044c3f5dda03: Loading layer [==================================================>] 66.56kB/66.56kB
7f8575cc2f03: Loading layer [==================================================>] 17.41kB/17.41kB
fe198ec7df1d: Loading layer [==================================================>] 15.36kB/15.36kB
Loaded image: goharbor/harbor-portal:v2.1.3
d3f717b5d596: Loading layer [==================================================>] 8.072MB/8.072MB
c8ee2f4f6699: Loading layer [==================================================>] 3.584kB/3.584kB
cfd1bf008a6d: Loading layer [==================================================>] 2.56kB/2.56kB
8e5472b7ed8e: Loading layer [==================================================>] 54.29MB/54.29MB
1db003052be5: Loading layer [==================================================>] 5.632kB/5.632kB
0231f7ea2d72: Loading layer [==================================================>] 60.42kB/60.42kB
30adb3e2679a: Loading layer [==================================================>] 11.78kB/11.78kB
3e996609c673: Loading layer [==================================================>] 55.11MB/55.11MB
5a263b512f9b: Loading layer [==================================================>] 2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.1.3
4ab370c63b3e: Loading layer [==================================================>] 4.933MB/4.933MB
975554788330: Loading layer [==================================================>] 4.096kB/4.096kB
f5b3cc09bcd8: Loading layer [==================================================>] 20.52MB/20.52MB
b0d97cd18eaa: Loading layer [==================================================>] 3.072kB/3.072kB
8c151b2c13a1: Loading layer [==================================================>] 25.91MB/25.91MB
46141b0f7c27: Loading layer [==================================================>] 47.24MB/47.24MB
Loaded image: goharbor/harbor-registryctl:v2.1.3
f7a5d87c04ff: Loading layer [==================================================>] 4.933MB/4.933MB
c1039e70b721: Loading layer [==================================================>] 4.096kB/4.096kB
cd55b5894269: Loading layer [==================================================>] 3.072kB/3.072kB
e24bd6c19f05: Loading layer [==================================================>] 20.52MB/20.52MB
059fdb11b68d: Loading layer [==================================================>] 21.34MB/21.34MB
Loaded image: goharbor/registry-photon:v2.1.3
a9cfe4782868: Loading layer [==================================================>] 4.932MB/4.932MB
162006658ae1: Loading layer [==================================================>] 66.44MB/66.44MB
6d5f2cc77950: Loading layer [==================================================>] 3.072kB/3.072kB
6816015fc840: Loading layer [==================================================>] 4.096kB/4.096kB
e4c3d5662925: Loading layer [==================================================>] 67.27MB/67.27MB
Loaded image: goharbor/chartmuseum-photon:v2.1.3
eda39f992504: Loading layer [==================================================>] 63.76MB/63.76MB
c7c394f98360: Loading layer [==================================================>] 78.31MB/78.31MB
0b11b6716b75: Loading layer [==================================================>] 6.144kB/6.144kB
480b5d61510d: Loading layer [==================================================>] 2.56kB/2.56kB
3ecace3c592e: Loading layer [==================================================>] 2.56kB/2.56kB
dbbf26bda64a: Loading layer [==================================================>] 2.56kB/2.56kB
df1508a63326: Loading layer [==================================================>] 2.56kB/2.56kB
8038a87c58d7: Loading layer [==================================================>] 11.26kB/11.26kB
Loaded image: goharbor/harbor-db:v2.1.3
8a27b2778538: Loading layer [==================================================>] 8.071MB/8.071MB
2fe3f1b054fd: Loading layer [==================================================>] 3.584kB/3.584kB
3b9bcd275166: Loading layer [==================================================>] 2.56kB/2.56kB
4fffc560d75a: Loading layer [==================================================>] 63.96MB/63.96MB
d611dea267cc: Loading layer [==================================================>] 64.79MB/64.79MB
Loaded image: goharbor/harbor-jobservice:v2.1.3
ee9b7dd248e7: Loading layer [==================================================>] 4.926MB/4.926MB
0aa357fcc019: Loading layer [==================================================>] 6.364MB/6.364MB
2ac0e6fa0264: Loading layer [==================================================>] 15.85MB/15.85MB
3b0b24bd5046: Loading layer [==================================================>] 27.98MB/27.98MB
e1dfc9702755: Loading layer [==================================================>] 22.02kB/22.02kB
2059a87ed2d1: Loading layer [==================================================>] 15.85MB/15.85MB
Loaded image: goharbor/notary-server-photon:v2.1.3
608d2a651494: Loading layer [==================================================>] 4.933MB/4.933MB
5cf58e1bb720: Loading layer [==================================================>] 4.096kB/4.096kB
ad914f98210d: Loading layer [==================================================>] 3.072kB/3.072kB
39894ca7b73a: Loading layer [==================================================>] 13.01MB/13.01MB
2139b6d15c37: Loading layer [==================================================>] 13.83MB/13.83MB
Loaded image: goharbor/clair-adapter-photon:v2.1.3
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/tools/harbor
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Successfully called func: create_root_cert
Successfully called func: create_cert
Copying certs for notary signer
Copying nginx configuration file for notary
Generated configuration file: /config/nginx/conf.d/notary.upstream.conf
Generated configuration file: /config/nginx/conf.d/notary.server.conf
Generated configuration file: /config/notary/server-config.postgres.json
Generated configuration file: /config/notary/server_env
Generated and saved secret to file: /data/secret/keys/defaultalias
Generated configuration file: /config/notary/signer_env
Generated configuration file: /config/notary/signer-config.postgres.json
Generated configuration file: /config/clair/postgres_env
Generated configuration file: /config/clair/config.yaml
Generated configuration file: /config/clair/clair_env
Generated configuration file: /config/clair-adapter/env
Generated configuration file: /config/trivy-adapter/env
Generated configuration file: /config/chartserver/env
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating network "harbor_harbor-clair" with the default driver
Creating network "harbor_harbor-notary" with the default driver
Creating network "harbor_harbor-chartmuseum" with the default driver
Creating network "harbor_notary-sig" with the default driver
Creating harbor-log ... done
Creating registryctl ... done
Creating redis ... done
Creating harbor-portal ... done
Creating registry ... done
Creating harbor-db ... done
Creating chartmuseum ... done
Creating trivy-adapter ... done
Creating harbor-core ... done
Creating notary-signer ... done
Creating clair ... done
Creating notary-server ... done
Creating clair-adapter ... done
Creating harbor-jobservice ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
第四步,查看Harbor进程
# docker-compose ps
第五步,登陆Harbor
默认密码为:Harbor12345,登陆后务必要修改默认的管理员密码。
Harbor的开源协议:
附:
Harbor的停启
# docker-compose stop
# docker-compose start
备注:执行docker-compose的时候,需要使用 -f /path-to-docker-compose/docker-compose.yml 参数指定docker-compose.yml文件的位置,或者切换到docker-compose.yml文件所在的目录下,再执行。