Docker安装Harbor
将此文章写给我最心爱的女孩
目录
1.安装docker、docker-compose
yum install docker-ce-20.10.9 -y
yum install epel-release -y
yum install docker-compose –y
2.下载Harbor安装包
下载地址
下载会有点慢,建议用迅雷下载
下载的harbor-offline-installer-v1.10.10.tgz 包通过ftp工具拉取到服务器上
3.解压安装包
tar zxvf harbor-offline-installer-v1.10.10.tgz
显示
[root@localhost harbor]# tar zxvf harbor-offline-installer-v1.10.10.tgz
harbor/harbor.v1.10.10.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml
解压之后会生成harbor文件夹,cd进去
[root@localhost harbor]# ls
common common.sh docker-compose.yml harbor.v1.10.10.tar.gz harbor.yml install.sh LICENSE prepare
4.Docker加载harbor镜像
docker load -i harbor.v1.10.10.tar.gz
显示
[root@localhost harbor]# ls
harbor harbor-offline-installer-v1.10.10.tgz
[root@localhost harbor]# cd harbor
[root@localhost harbor]# ls
common.sh harbor.v1.10.10.tar.gz harbor.yml install.sh LICENSE prepare
[root@localhost harbor]# docker load -i harbor.v1.10.10.tar.gz
454bac8f976d: Loading layer [==================================================>] 34.62MB/34.62MB
babe85b686ad: Loading layer [==================================================>] 11.4MB/11.4MB
259a4c53fb16: Loading layer [==================================================>] 7.697MB/7.697MB
98ac3dea2937: Loading layer [==================================================>] 223.2kB/223.2kB
cdaa2acc770f: Loading layer [==================================================>] 195.1kB/195.1kB
0a48234d6364: Loading layer [==================================================>] 15.36kB/15.36kB
173c8c58ac9c: Loading layer [==================================================>] 3.584kB/3.584kB
Loaded image: goharbor/harbor-portal:v1.10.10
b380398fcbd9: Loading layer [==================================================>] 9.549MB/9.549MB
bc529c783a53: Loading layer [==================================================>] 3.584kB/3.584kB
e9ce0315169d: Loading layer [==================================================>] 3.072kB/3.072kB
67bd603fe25a: Loading layer [==================================================>] 18.95MB/18.95MB
14e24ca9b198: Loading layer [==================================================>] 19.78MB/19.78MB
Loaded image: goharbor/registry-photon:v1.10.10
6230e8094809: Loading layer [==================================================>] 9.549MB/9.549MB
0a9687793924: Loading layer [==================================================>] 12.09MB/12.09MB
82b02208b278: Loading layer [==================================================>] 12.09MB/12.09MB
Loaded image: goharbor/clair-adapter-photon:v1.10.10
facb3a7ee1e6: Loading layer [==================================================>] 9.549MB/9.549MB
81d29f7fac9d: Loading layer [==================================================>] 62.66MB/62.66MB
37883bc38d7c: Loading layer [==================================================>] 3.072kB/3.072kB
8aa48f380871: Loading layer [==================================================>] 3.584kB/3.584kB
c5681a8ef18a: Loading layer [==================================================>] 63.48MB/63.48MB
Loaded image: goharbor/chartmuseum-photon:v1.10.10
56bbc9cc94cf: Loading layer [==================================================>] 9.544MB/9.544MB
a207919569bf: Loading layer [==================================================>] 5.925MB/5.925MB
0a29582a26cd: Loading layer [==================================================>] 13.33MB/13.33MB
1b0a8ff5a816: Loading layer [==================================================>] 26.35MB/26.35MB
6dbcc574c94e: Loading layer [==================================================>] 22.02kB/22.02kB
f166ede0750a: Loading layer [==================================================>] 13.33MB/13.33MB
Loaded image: goharbor/notary-signer-photon:v1.10.10
86aaaa5372f8: Loading layer [==================================================>] 119.8MB/119.8MB
819275c346fd: Loading layer [==================================================>] 48.71MB/48.71MB
ea77710b7898: Loading layer [==================================================>] 2.56kB/2.56kB
ca2a3efc6750: Loading layer [==================================================>] 1.536kB/1.536kB
dfe233b9926d: Loading layer [==================================================>] 155.6kB/155.6kB
c3a75b2ecccd: Loading layer [==================================================>] 1.776MB/1.776MB
Loaded image: goharbor/prepare:v1.10.10
a4ba54e44ac3: Loading layer [==================================================>] 13.31MB/13.31MB
f1e6788f29b8: Loading layer [==================================================>] 35.84MB/35.84MB
e570535efa12: Loading layer [==================================================>] 5.632kB/5.632kB
cecb134ae993: Loading layer [==================================================>] 40.45kB/40.45kB
b1df430d541c: Loading layer [==================================================>] 2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v1.10.10
9d61b49d78e8: Loading layer [==================================================>] 9.549MB/9.549MB
27d61b3545b1: Loading layer [==================================================>] 3.584kB/3.584kB
a2244026b9bc: Loading layer [==================================================>] 18.95MB/18.95MB
03c5dc84f868: Loading layer [==================================================>] 3.072kB/3.072kB
9b69c5c3d773: Loading layer [==================================================>] 7.739MB/7.739MB
edbd121a3ef0: Loading layer [==================================================>] 27.51MB/27.51MB
Loaded image: goharbor/harbor-registryctl:v1.10.10
f11324788e5e: Loading layer [==================================================>] 116.1MB/116.1MB
9594b2b5491a: Loading layer [==================================================>] 3.072kB/3.072kB
51e6f741940c: Loading layer [==================================================>] 59.9kB/59.9kB
4885c950d461: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.10.10
1eacc09320d3: Loading layer [==================================================>] 75.89MB/75.89MB
a3e3ad0e02b9: Loading layer [==================================================>] 3.584kB/3.584kB
b372494191eb: Loading layer [==================================================>] 3.072kB/3.072kB
1aad5535a60c: Loading layer [==================================================>] 2.56kB/2.56kB
986f9c984b66: Loading layer [==================================================>] 3.072kB/3.072kB
c143cc1290af: Loading layer [==================================================>] 3.584kB/3.584kB
a31a89cc6444: Loading layer [==================================================>] 12.29kB/12.29kB
3e91299418d7: Loading layer [==================================================>] 3.584kB/3.584kB
Loaded image: goharbor/harbor-log:v1.10.10
784f32f21e7f: Loading layer [==================================================>] 65.05MB/65.05MB
53f565435ba3: Loading layer [==================================================>] 91.13MB/91.13MB
2f17e0297083: Loading layer [==================================================>] 5.632kB/5.632kB
43bb299bbeb4: Loading layer [==================================================>] 2.56kB/2.56kB
b3851907b9a7: Loading layer [==================================================>] 2.56kB/2.56kB
e20d492b0d2f: Loading layer [==================================================>] 2.56kB/2.56kB
8593e00e527b: Loading layer [==================================================>] 2.56kB/2.56kB
064073f4d6fa: Loading layer [==================================================>] 10.75kB/10.75kB
Loaded image: goharbor/harbor-db:v1.10.10
3d696a50ec47: Loading layer [==================================================>] 13.31MB/13.31MB
158c565cf55a: Loading layer [==================================================>] 43.21MB/43.21MB
Loaded image: goharbor/harbor-jobservice:v1.10.10
6a7bbce7dc58: Loading layer [==================================================>] 5.925MB/5.925MB
a3ff85fb97ac: Loading layer [==================================================>] 14.86MB/14.86MB
afa213836201: Loading layer [==================================================>] 26.35MB/26.35MB
6b644a4c4d8f: Loading layer [==================================================>] 22.02kB/22.02kB
2832a6621437: Loading layer [==================================================>] 14.86MB/14.86MB
Loaded image: goharbor/notary-server-photon:v1.10.10
883a6e0d9000: Loading layer [==================================================>] 11.4MB/11.4MB
Loaded image: goharbor/nginx-photon:v1.10.10
8d231d997136: Loading layer [==================================================>] 123.1MB/123.1MB
8598b2dba190: Loading layer [==================================================>] 11.97MB/11.97MB
ddbec80c9a88: Loading layer [==================================================>] 3.072kB/3.072kB
0a79796e5549: Loading layer [==================================================>] 49.15kB/49.15kB
63fb85041d48: Loading layer [==================================================>] 3.584kB/3.584kB
6eb19cef8f23: Loading layer [==================================================>] 12.84MB/12.84MB
Loaded image: goharbor/clair-photon:v1.10.10
[root@localhost harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/chartmuseum-photon v1.10.10 b8add6b726bb 13 months ago 169MB
goharbor/redis-photon v1.10.10 da80bdfe2937 13 months ago 149MB
goharbor/clair-adapter-photon v1.10.10 914f98d8a471 13 months ago 67.3MB
goharbor/clair-photon v1.10.10 ec877cd064a9 13 months ago 178MB
goharbor/notary-server-photon v1.10.10 90981e58f79f 13 months ago 105MB
goharbor/notary-signer-photon v1.10.10 e50ee961a9d6 13 months ago 102MB
goharbor/harbor-registryctl v1.10.10 8cff0f50ad4a 13 months ago 97.3MB
goharbor/registry-photon v1.10.10 465538cf61bc 13 months ago 81.8MB
goharbor/nginx-photon v1.10.10 86473ef9ef24 13 months ago 44.9MB
goharbor/harbor-log v1.10.10 c9cb00a7af3e 13 months ago 108MB
goharbor/harbor-jobservice v1.10.10 d244473b6165 13 months ago 88.8MB
goharbor/harbor-core v1.10.10 b3be36cace3a 13 months ago 81.5MB
goharbor/harbor-portal v1.10.10 1980673cc854 13 months ago 53MB
goharbor/harbor-db v1.10.10 0c6ce792483e 13 months ago 187MB
goharbor/prepare v1.10.10 475fb37cdd49 13 months ago 200MB
[root@localhost harbor]#
5.修改配置文件
[root@localhost harbor]# cd harbor
[root@localhost harbor]# ls
common.sh harbor.v1.10.10.tar.gz harbor.yml install.sh LICENSE prepare
[root@localhost harbor]# vim harbor.yml
设置主机名和密码:192.168.85.139 Harbor12345
将上面的https:内容都进行注释,否则会出错:ERROR:root:Error: The protocol is https but attribute ssl_cert is not set
6.执行**./prepare && ./install.sh**命令
[root@localhost harbor]# ./prepare
prepare base dir is set to /home/harbor/harbor
/usr/src/app/utils/configs.py:100: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
configs = yaml.load(f)
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
/usr/src/app/utils/configs.py:90: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
versions = yaml.load(f)
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/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
[root@localhost harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 23.0.1
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.18.0
[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-portal:v1.10.10
Loaded image: goharbor/registry-photon:v1.10.10
Loaded image: goharbor/clair-adapter-photon:v1.10.10
Loaded image: goharbor/chartmuseum-photon:v1.10.10
Loaded image: goharbor/notary-signer-photon:v1.10.10
Loaded image: goharbor/prepare:v1.10.10
Loaded image: goharbor/harbor-core:v1.10.10
Loaded image: goharbor/harbor-registryctl:v1.10.10
Loaded image: goharbor/redis-photon:v1.10.10
Loaded image: goharbor/harbor-log:v1.10.10
Loaded image: goharbor/harbor-db:v1.10.10
Loaded image: goharbor/harbor-jobservice:v1.10.10
Loaded image: goharbor/notary-server-photon:v1.10.10
Loaded image: goharbor/nginx-photon:v1.10.10
Loaded image: goharbor/clair-photon:v1.10.10
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /home/harbor/harbor
/usr/src/app/utils/configs.py:100: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
configs = yaml.load(f)
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
/usr/src/app/utils/configs.py:90: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
versions = yaml.load(f)
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
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/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Creating harbor-log ... done
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
Creating registry ... done
Creating harbor-core ... done
Creating network "harbor_harbor" with the default driver
Creating harbor-jobservice ... done
Creating harbor-portal ...
Creating harbor-db ...
Creating registryctl ...
Creating registry ...
Creating redis ...
Creating harbor-core ...
Creating harbor-jobservice ...
Creating nginx ...
✔ ----Harbor has been installed and started successfully.----
7.查看相关镜像
[root@localhost harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1c2c49bcae29 goharbor/nginx-photon:v1.10.10 "nginx -g 'daemon of…" 47 seconds ago Up 45 seconds (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp nginx
bce07bf48d57 goharbor/harbor-jobservice:v1.10.10 "/harbor/harbor_jobs…" 47 seconds ago Up 45 seconds (healthy) harbor-jobservice
43a696210739 goharbor/harbor-core:v1.10.10 "/harbor/harbor_core" 48 seconds ago Up 46 seconds (healthy) harbor-core
2c460dcf924f goharbor/registry-photon:v1.10.10 "/home/harbor/entryp…" 50 seconds ago Up 47 seconds (healthy) 5000/tcp registry
8904cb8b36e2 goharbor/redis-photon:v1.10.10 "redis-server /etc/r…" 50 seconds ago Up 48 seconds (healthy) 6379/tcp redis
9b030e10048b goharbor/harbor-registryctl:v1.10.10 "/home/harbor/start.…" 50 seconds ago Up 48 seconds (healthy) registryctl
7613eb27e887 goharbor/harbor-db:v1.10.10 "/docker-entrypoint.…" 50 seconds ago Up 48 seconds (healthy) 5432/tcp harbor-db
ab698202e684 goharbor/harbor-portal:v1.10.10 "nginx -g 'daemon of…" 50 seconds ago Up 47 seconds (healthy) 8080/tcp harbor-portal
62496f80be73 goharbor/harbor-log:v1.10.10 "/bin/sh -c /usr/loc…" 52 seconds ago Up 49 seconds (healthy) 127.0.0.1:1514->10514/tcp harbor-log
[root@localhost harbor]#
8.访问测试,浏览器输入ip即可
用户名是admin,密码在上面的配置文件里有 Harbor12345