1、系統環境說明
操做系統版本:CentOS 7.4.1708
harbor01:10.0.0.134
harbor02: 10.0.0.135
一、準備基礎環境:
linux
[root@localhost ~]# hostnamectl set-hostname Harbor01.example.com [root@localhost ~]# sudo -i [root@harbor01 ~]#
二、Docker環境的準備:
nginx
[root@harbor01 ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2 [root@harbor01 ~]# sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo [root@harbor01 ~]# yum makecache fast && yum -y install docker-ce [root@harbor01 ~]# sudo service docker start Redirecting to /bin/systemctl start docker.service [root@harbor01 ~]# systemctl enable docker.service Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@harbor01 harbor]# vim /usr/lib/systemd/system/docker.service 將"ExecStart=/usr/bin/dockerd" "ExecStart=/usr/bin/dockerd --registry-mirror=https://fo7k1r42.mirror.aliyuncs.com" [root@harbor01 harbor]# systemctl daemon-reload && systemctl restart docker.service && systemctl status docker.service
三、準備docker-compose
git
[root@harbor01 ~]# yum -y install docker-compose [root@harbor01 ~]# cd /opt/ [root@harbor01 opt]# ll total 642244 -rw-r--r-- 1 root root 657657134 Sep 3 18:00 harbor-offline-installer-v1.6.0-rc2.tgz [root@harbor01 opt]# tar -xf harbor-offline-installer-v1.6.0-rc2.tgz [root@harbor01 opt]# cd harbor [root@harbor01 harbor]# ll total 649596 drwxr-xr-x 3 root root 23 Sep 3 18:07 common -rw-r--r-- 1 root root 672 Aug 23 18:17 docker-compose.chartmuseum.yml -rw-r--r-- 1 root root 777 Aug 23 18:17 docker-compose.clair.yml -rw-r--r-- 1 root root 1258 Aug 23 18:17 docker-compose.notary.yml -rw-r--r-- 1 root root 3589 Aug 23 18:17 docker-compose.yml drwxr-xr-x 3 root root 164 Aug 23 18:17 ha -rw-r--r-- 1 root root 7616 Aug 23 18:17 harbor.cfg -rw-r--r-- 1 root root 663558746 Aug 23 18:18 harbor.v1.6.0.tar.gz -rwxr-xr-x 1 root root 6162 Aug 23 18:17 install.sh -rw-r--r-- 1 root root 10768 Aug 23 18:17 LICENSE -rw-r--r-- 1 root root 482 Aug 23 18:17 NOTICE -rw-r--r-- 1 root root 1539982 Aug 23 18:17 open_source_license -rwxr-xr-x 1 root root 36833 Aug 23 18:17 prepare [root@harbor01 harbor]# vim harbor.cfg _version = 1.6.0 hostname = 10.0.0.134 ui_url_protocol = http max_job_workers = 10 customize_crt = on ssl_cert = /data/cert/server.crt ssl_cert_key = /data/cert/server.key secretkey_path = /data admiral_url = NA log_rotate_count = 50 log_rotate_size = 200M http_proxy = https_proxy = no_proxy = 127.0.0.1,localhost,ui,registry email_identity = email_server = smtp.mydomain.com email_server_port = 25 email_username = sample_admin@mydomain.com email_password = abc email_from = admin <sample_admin@mydomain.com> email_ssl = false email_insecure = false harbor_admin_password = Harbor12345 auth_mode = db_auth ldap_url = ldaps://ldap.mydomain.com ldap_basedn = ou=people,dc=mydomain,dc=com ldap_uid = uid ldap_scope = 2 ldap_timeout = 5 ldap_verify_cert = true ldap_group_basedn = ou=group,dc=mydomain,dc=com ldap_group_filter = objectclass=group ldap_group_gid = cn ldap_group_scope = 2 self_registration = on token_expiration = 30 project_creation_restriction = everyone db_host = postgresql db_password = root123 db_port = 5432 db_user = postgres redis_host = redis redis_port = 6379 redis_password = redis_db_index = 1,2,3 clair_db_host = postgresql clair_db_password = root123 clair_db_port = 5432 clair_db_username = postgres clair_db = postgres clair_updaters_interval = 0 uaa_endpoint = uaa.mydomain.org uaa_clientid = id uaa_clientsecret = secret uaa_verify_cert = true uaa_ca_cert = /path/to/ca.pem registry_storage_provider_name = filesystem registry_storage_provider_config = registry_custom_ca_bundle = [root@harbor01 harbor]# ./install.sh [Step 0]: checking installation environment ... Note: docker version: 18.03.1 Note: docker-compose version: 1.9.0 [Step 1]: loading Harbor images ... dba693fc2701: Loading layer [==================================================>] 133.4MB/133.4MB 82760fc83dbe: Loading layer [==================================================>] 95.85MB/95.85MB f6757d6240a0: Loading layer [==================================================>] 6.656kB/6.656kB 96fb31113390: Loading layer [==================================================>] 2.048kB/2.048kB 23570810435c: Loading layer [==================================================>] 7.68kB/7.68kB d2d055ddf167: Loading layer [==================================================>] 2.56kB/2.56kB 4127dc28bf1e: Loading layer [==================================================>] 2.56kB/2.56kB 192878e9f735: Loading layer [==================================================>] 2.56kB/2.56kB Loaded image: goharbor/harbor-db:v1.6.0 595c41538a1d: Loading layer [==================================================>] 683.6MB/683.6MB 8eba1a408d54: Loading layer [==================================================>] 7.68kB/7.68kB 43f2460f0627: Loading layer [==================================================>] 197.6kB/197.6kB Loaded image: goharbor/harbor-migrator:v1.6.0 4e3f9f66d27d: Loading layer [==================================================>] 158.7MB/158.7MB 331cfb7d2666: Loading layer [==================================================>] 35.08MB/35.08MB ba236e748738: Loading layer [==================================================>] 2.048kB/2.048kB 7915b53459f6: Loading layer [==================================================>] 35.08MB/35.08MB Loaded image: goharbor/chartmuseum-photon:v0.7.1-v1.6.0 73bb0207521c: Loading layer [==================================================>] 23.38MB/23.38MB 8e7df4492382: Loading layer [==================================================>] 15.58MB/15.58MB 16fd4d7aa39a: Loading layer [==================================================>] 15.36kB/15.36kB 024d462feb48: Loading layer [==================================================>] 15.58MB/15.58MB Loaded image: goharbor/harbor-adminserver:v1.6.0 15498b7cc37e: Loading layer [==================================================>] 23.38MB/23.38MB 75f5cf3862bb: Loading layer [==================================================>] 26.87MB/26.87MB 8851addecf8f: Loading layer [==================================================>] 7.168kB/7.168kB bb2981a895d2: Loading layer [==================================================>] 11.32MB/11.32MB 1afabee7de3c: Loading layer [==================================================>] 26.86MB/26.86MB Loaded image: goharbor/harbor-ui:v1.6.0 bee39bccef74: Loading layer [==================================================>] 82.45MB/82.45MB 87922b4b8808: Loading layer [==================================================>] 3.072kB/3.072kB 3452c1cd15a2: Loading layer [==================================================>] 59.9kB/59.9kB 157616b98a89: Loading layer [==================================================>] 61.95kB/61.95kB Loaded image: goharbor/redis-photon:v1.6.0 f98e2a8454e9: Loading layer [==================================================>] 5.11MB/5.11MB Loaded image: goharbor/nginx-photon:v1.6.0 ab667dbfdfa4: Loading layer [==================================================>] 23.38MB/23.38MB ca8756cefca9: Loading layer [==================================================>] 3.072kB/3.072kB 1d2b114e4fa1: Loading layer [==================================================>] 3.072kB/3.072kB 24c26b028646: Loading layer [==================================================>] 2.048kB/2.048kB 3afd936e95bb: Loading layer [==================================================>] 22.8MB/22.8MB 8069a7d7f653: Loading layer [==================================================>] 22.8MB/22.8MB Loaded image: goharbor/registry-photon:v2.6.2-v1.6.0 879bb2bab9c6: Loading layer [==================================================>] 23.38MB/23.38MB 3f4f71237653: Loading layer [==================================================>] 12.16MB/12.16MB 505a8d9e1cc9: Loading layer [==================================================>] 17.3MB/17.3MB 1dd9f79b96b9: Loading layer [==================================================>] 11.26kB/11.26kB 7126e1157745: Loading layer [==================================================>] 3.072kB/3.072kB 9ab0e7735ffa: Loading layer [==================================================>] 29.46MB/29.46MB Loaded image: goharbor/notary-server-photon:v0.5.1-v1.6.0 02ce56a4ccfa: Loading layer [==================================================>] 10.95MB/10.95MB ae6e25287872: Loading layer [==================================================>] 17.3MB/17.3MB 57145e551d1b: Loading layer [==================================================>] 11.26kB/11.26kB ad03e9bdc145: Loading layer [==================================================>] 3.072kB/3.072kB 31cde1889527: Loading layer [==================================================>] 28.24MB/28.24MB Loaded image: goharbor/notary-signer-photon:v0.5.1-v1.6.0 a27f77323aea: Loading layer [==================================================>] 158.7MB/158.7MB 86ffa73065d3: Loading layer [==================================================>] 10.93MB/10.93MB 038a4fbcaeca: Loading layer [==================================================>] 2.048kB/2.048kB 90f20c479b6f: Loading layer [==================================================>] 48.13kB/48.13kB 876c20bc9014: Loading layer [==================================================>] 10.97MB/10.97MB Loaded image: goharbor/clair-photon:v2.0.4-v1.6.0 9ba727087641: Loading layer [==================================================>] 73.27MB/73.27MB 7623258729f0: Loading layer [==================================================>] 3.584kB/3.584kB 21f726e50e61: Loading layer [==================================================>] 3.072kB/3.072kB a6d7eec3bd36: Loading layer [==================================================>] 4.096kB/4.096kB d074135eff88: Loading layer [==================================================>] 3.584kB/3.584kB e6ed47e59145: Loading layer [==================================================>] 9.728kB/9.728kB Loaded image: goharbor/harbor-log:v1.6.0 fe90bcbf47a1: Loading layer [==================================================>] 23.38MB/23.38MB 380adc5786b7: Loading layer [==================================================>] 21.15MB/21.15MB 11e9f7606582: Loading layer [==================================================>] 21.15MB/21.15MB Loaded image: goharbor/harbor-jobservice:v1.6.0 [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/registryctl/env 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. [Step 3]: checking existing instance of Harbor ... [Step 4]: starting Harbor ... Creating network "harbor_harbor" with the default driver Creating harbor-log Creating harbor-db Creating registry Creating harbor-adminserver Creating redis Creating harbor-ui Creating nginx Creating harbor-jobservice ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://10.0.0.134. For more details, please visit https://github.com/goharbor/harbor .
使用admin和對應密碼登陸到habor中
github
說明:配置郵箱redis
說明:添加倉庫sql
說明:倉庫管理
docker
查看鏡像信息:
json
[root@harbor01 harbor]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE goharbor/chartmuseum-photon v0.7.1-v1.6.0 446eef5f2236 11 days ago 351MB goharbor/harbor-migrator v1.6.0 3980a210810f 11 days ago 798MB goharbor/redis-photon v1.6.0 a32d71ae6b2a 11 days ago 208MB goharbor/clair-photon v2.0.4-v1.6.0 e920ed1ae133 11 days ago 303MB goharbor/notary-server-photon v0.5.1-v1.6.0 992413e8131f 11 days ago 209MB goharbor/notary-signer-photon v0.5.1-v1.6.0 89615d2149a3 11 days ago 207MB goharbor/registry-photon v2.6.2-v1.6.0 9840f2f597a7 11 days ago 196MB goharbor/nginx-photon v1.6.0 7e7891c4dc87 11 days ago 132MB goharbor/harbor-log v1.6.0 5dc2a8ee4199 11 days ago 198MB goharbor/harbor-jobservice v1.6.0 88d34b92d3b6 11 days ago 192MB goharbor/harbor-ui v1.6.0 28a91bc7524c 11 days ago 215MB goharbor/harbor-adminserver v1.6.0 55b5e7b3855d 11 days ago 181MB goharbor/harbor-db v1.6.0 c405e5a7f46e 11 days ago 219MB [root@harbor01 harbor]# docker-compose ps Name Command State Ports ------------------------------------------------------------------------------------------------------------------------------ harbor-adminserver /harbor/start.sh Up harbor-db /entrypoint.sh postgres Up 5432/tcp harbor-jobservice /harbor/start.sh Up harbor-log /bin/sh -c /usr/local/bin/ ... Up 127.0.0.1:1514->10514/tcp harbor-ui /harbor/start.sh Up nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp redis docker-entrypoint.sh redis ... Up 6379/tcp registry /entrypoint.sh /etc/regist ... Up 5000/tcp
[root@harbor01 ~]# docker login 10.0.0.134
Username: admin
Password:
Error response from daemon: Get https://10.0.0.163/v2/: dial tcp 10.0.0.134:443: getsockopt: connection refused
[root@harbor01 harbor]# vim /etc/docker/daemon.json
{ "insecure-registries":["10.0.0.134"] }
[root@harbor01 harbor]# systemctl daemon-reload && systemctl restart docker
[root@harbor01 harbor]# docker login 10.0.0.134
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@harbor01 harbor]# docker pull centos
[root@harbor01 harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/chartmuseum-photon v0.7.1-v1.6.0 446eef5f2236 11 days ago 351MB
goharbor/harbor-migrator v1.6.0 3980a210810f 11 days ago 798MB
goharbor/redis-photon v1.6.0 a32d71ae6b2a 11 days ago 208MB
goharbor/clair-photon v2.0.4-v1.6.0 e920ed1ae133 11 days ago 303MB
goharbor/notary-server-photon v0.5.1-v1.6.0 992413e8131f 11 days ago 209MB
goharbor/notary-signer-photon v0.5.1-v1.6.0 89615d2149a3 11 days ago 207MB
goharbor/registry-photon v2.6.2-v1.6.0 9840f2f597a7 11 days ago 196MB
goharbor/nginx-photon v1.6.0 7e7891c4dc87 11 days ago 132MB
goharbor/harbor-log v1.6.0 5dc2a8ee4199 11 days ago 198MB
goharbor/harbor-jobservice v1.6.0 88d34b92d3b6 11 days ago 192MB
goharbor/harbor-ui v1.6.0 28a91bc7524c 11 days ago 215MB
goharbor/harbor-adminserver v1.6.0 55b5e7b3855d 11 days ago 181MB
goharbor/harbor-db v1.6.0 c405e5a7f46e 11 days ago 219MB
centos latest 5182e96772bf 3 weeks ago 200MB
[root@harbor01 harbor]# docker tag centos 10.0.0.134/t1/centos
[root@harbor01 harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/chartmuseum-photon v0.7.1-v1.6.0 446eef5f2236 11 days ago 351MB
goharbor/harbor-migrator v1.6.0 3980a210810f 11 days ago 798MB
goharbor/redis-photon v1.6.0 a32d71ae6b2a 11 days ago 208MB
goharbor/clair-photon v2.0.4-v1.6.0 e920ed1ae133 11 days ago 303MB
goharbor/notary-server-photon v0.5.1-v1.6.0 992413e8131f 11 days ago 209MB
goharbor/notary-signer-photon v0.5.1-v1.6.0 89615d2149a3 11 days ago 207MB
goharbor/registry-photon v2.6.2-v1.6.0 9840f2f597a7 11 days ago 196MB
goharbor/nginx-photon v1.6.0 7e7891c4dc87 11 days ago 132MB
goharbor/harbor-log v1.6.0 5dc2a8ee4199 11 days ago 198MB
goharbor/harbor-jobservice v1.6.0 88d34b92d3b6 11 days ago 192MB
goharbor/harbor-ui v1.6.0 28a91bc7524c 11 days ago 215MB
goharbor/harbor-adminserver v1.6.0 55b5e7b3855d 11 days ago 181MB
goharbor/harbor-db v1.6.0 c405e5a7f46e 11 days ago 219MB
centos latest 5182e96772bf 3 weeks ago 200MB
10.0.0.134/t1/centos latest 5182e96772bf 3 weeks ago 200MB
推送鏡像到指定倉庫:
[root@harbor01 harbor]# docker push 10.0.0.134/t1/centos
The push refers to repository [10.0.0.134/t1/centos]
1d31b5806ba4: Pushed
latest: digest: sha256:fc2476ccae2a5186313f2d1dadb4a969d6d2d4c6b23fa98b6c7b0a1faad67685 size: 529
Harbor域數據複製:
a)若是須要修改Harbor的配置文件harbor.cfg,由於Harbor是基於docker-compose服務編排的,咱們能夠使用docker-compose命令重啓Harbor。
b)不修改配置文件,重啓Harbor命令:docker-compose start | stop | restart
驗證:
[root@harbor01 harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/chartmuseum-photon v0.7.1-v1.6.0 446eef5f2236 11 days ago 351MB
goharbor/harbor-migrator v1.6.0 3980a210810f 11 days ago 798MB
goharbor/redis-photon v1.6.0 a32d71ae6b2a 11 days ago 208MB
goharbor/clair-photon v2.0.4-v1.6.0 e920ed1ae133 11 days ago 303MB
goharbor/notary-server-photon v0.5.1-v1.6.0 992413e8131f 11 days ago 209MB
goharbor/notary-signer-photon v0.5.1-v1.6.0 89615d2149a3 11 days ago 207MB
goharbor/registry-photon v2.6.2-v1.6.0 9840f2f597a7 11 days ago 196MB
goharbor/nginx-photon v1.6.0 7e7891c4dc87 11 days ago 132MB
goharbor/harbor-log v1.6.0 5dc2a8ee4199 11 days ago 198MB
goharbor/harbor-jobservice v1.6.0 88d34b92d3b6 11 days ago 192MB
goharbor/harbor-ui v1.6.0 28a91bc7524c 11 days ago 215MB
goharbor/harbor-adminserver v1.6.0 55b5e7b3855d 11 days ago 181MB
goharbor/harbor-db v1.6.0 c405e5a7f46e 11 days ago 219MB
centos latest 5182e96772bf 3 weeks ago 200MB
10.0.0.134/t1/centos latest 5182e96772bf 3 weeks ago 200MB
10.0.0.134/t1/redis latest 4e8db158f18d 4 weeks ago 83.4MB
redis latest 4e8db158f18d 4 weeks ago 83.4MB
lemonbar/centos6-ssh latest efd998bd6817 4 years ago 297MB
[root@harbor01 harbor]# docker tag lemonbar/centos6-ssh 10.0.0.134/t1/centos6-ssh
[root@harbor01 harbor]# docker push 10.0.0.134/t1/centos6-ssh
The push refers to repository [10.0.0.134/t1/centos6-ssh]
5f70bf18a086: Pushed
5dde9e7abaae: Pushed
0d2c9d3bef41: Pushed
26231980c1a5: Pushed
7ec2a9eb1017: Pushed
29e0db08def6: Pushed
9225ac3d0295: Pushed
0f26de94dce0: Pushed
821f107b9dc4: Pushed
latest: digest: sha256:18d681aed592b9061e6358645e1c4d0f46a4b80a63f1628f63bdf7aa6b42f3e2 size: 3019
# 若是修改了harbor配置文件,想讓它生效,執行以下操做:
[root@harbor02 harbor]# pwd
/opt/harbor
[root@harbor02 harbor]# docker-compose down
[root@harbor02 harbor]# ./install.sh
vim