Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。
Harbor部署前提条件
硬件配置要求
CPU:最低2CPU,推荐4CPU
内存:最低4GB,推荐8GB
硬盘:最低40GB,推荐160GB
软件版本要求
Docker engine:17.06.0-ce或更高
Docker Compose:1.18.0或更高
本文以CentOS7为例来安装Harbor
1、安装依赖
1 |
yum install yum-utils device-mapper-persistent-data lvm2 |
2、安装docker-ce
1 2 |
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install docker-ce |
1 2 |
systemctl enable docker systemctl start docker |
1 2 |
docker --version Docker version 19.03.5, build 633a0ea |
3、安装docker-compose
1 2 3 |
wget https://github.com/docker/compose/releases/download/1.25.0/docker-compose-Linux-x86_64 mv docker-compose-Linux-x86_64 /usr/bin/docker-compose chmod +x /usr/bin/docker-compose |
1 2 |
docker-compose --version docker-compose version 1.25.0, build 0a186604 |
4、下载harbor离线安装包
1 2 |
wget https://github.com/goharbor/harbor/releases/download/v1.9.3/harbor-offline-installer-v1.9.3.tgz tar xf harbor-offline-installer-v1.9.3.tgz |
5、配置harbor
此处192.168.1.208为本机IP,当然也可以换成域名
1 2 |
sed -i "s|reg.mydomain.com|192.168.1.208|g" harbor/harbor.yml sed -i "s|Harbor12345|whsir.com|g" harbor/harbor.yml |
6、安装harbor
注意:--with-clair参数是启用漏洞扫描功能,相关内容请查看官方文档:https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
1 |
./harbor/install.sh --with-clair |
执行安装命令后会看到如下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
[Step 0]: checking installation environment ... Note: docker version: 19.03.5 Note: docker-compose version: 1.25.0 [Step 1]: loading Harbor images ... 47a4bb1cfbc7: Loading layer [==================================================>] 34.26MB/34.26MB f93c083be5bc: Loading layer [==================================================>] 9.009MB/9.009MB bf1b03029526: Loading layer [==================================================>] 44.41MB/44.41MB 3395eb0db37a: Loading layer [==================================================>] 2.048kB/2.048kB 630606b67737: Loading layer [==================================================>] 3.072kB/3.072kB b59ccb3639e4: Loading layer [==================================================>] 44.41MB/44.41MB Loaded image: goharbor/chartmuseum-photon:v0.9.0-v1.9.3 0801a4e2ebe9: Loading layer [==================================================>] 2.56kB/2.56kB e2b8ec162f1b: Loading layer [==================================================>] 1.536kB/1.536kB b68f30fd6125: Loading layer [==================================================>] 73.35MB/73.35MB fbe2002fa9e6: Loading layer [==================================================>] 42.63MB/42.63MB 105f3dfa58eb: Loading layer [==================================================>] 156.7kB/156.7kB 2395dbeaea9f: Loading layer [==================================================>] 3.006MB/3.006MB Loaded image: goharbor/prepare:v1.9.3 e80aab7b0662: Loading layer [==================================================>] 63.49MB/63.49MB f8b3d119e8a9: Loading layer [==================================================>] 54.42MB/54.42MB 5f496dd4633b: Loading layer [==================================================>] 5.632kB/5.632kB 9a2858fea72d: Loading layer [==================================================>] 2.048kB/2.048kB b7501a88cd95: Loading layer [==================================================>] 2.56kB/2.56kB c82e3969a2e2: Loading layer [==================================================>] 2.56kB/2.56kB 7cac869555ad: Loading layer [==================================================>] 2.56kB/2.56kB cca577be763d: Loading layer [==================================================>] 10.24kB/10.24kB Loaded image: goharbor/harbor-db:v1.9.3 9a508de7d2b7: Loading layer [==================================================>] 9.005MB/9.005MB 508382d944be: Loading layer [==================================================>] 3.072kB/3.072kB 6e9e3cb5d33e: Loading layer [==================================================>] 2.56kB/2.56kB 73ddaf5bf2d0: Loading layer [==================================================>] 21.76MB/21.76MB 9a276490655f: Loading layer [==================================================>] 21.76MB/21.76MB Loaded image: goharbor/registry-photon:v2.7.1-patch-2819-2553-v1.9.3 4a0251807cc9: Loading layer [==================================================>] 9.004MB/9.004MB 897af7ff7b63: Loading layer [==================================================>] 6.239MB/6.239MB 3f4123d93010: Loading layer [==================================================>] 14.9MB/14.9MB 4e0bdb09cba5: Loading layer [==================================================>] 29.21MB/29.21MB 29c5283b24ee: Loading layer [==================================================>] 22.02kB/22.02kB 6f09075fda1a: Loading layer [==================================================>] 50.34MB/50.34MB Loaded image: goharbor/notary-signer-photon:v0.6.1-v1.9.3 756ffb58fa91: Loading layer [==================================================>] 7.037MB/7.037MB 733009a88a23: Loading layer [==================================================>] 196.6kB/196.6kB 5cc05e9a6a60: Loading layer [==================================================>] 172kB/172kB eabe1b3a567b: Loading layer [==================================================>] 15.36kB/15.36kB dd83cfe76436: Loading layer [==================================================>] 3.584kB/3.584kB 28bde9e732c9: Loading layer [==================================================>] 10.84MB/10.84MB Loaded image: goharbor/harbor-portal:v1.9.3 0eb10921ee80: Loading layer [==================================================>] 78.25MB/78.25MB 74a7ce2b0571: Loading layer [==================================================>] 3.072kB/3.072kB 7d193a1c54ab: Loading layer [==================================================>] 59.9kB/59.9kB d45413cea5ea: Loading layer [==================================================>] 61.95kB/61.95kB Loaded image: goharbor/redis-photon:v1.9.3 7c53cafac35a: Loading layer [==================================================>] 337.9MB/337.9MB c6bad7449208: Loading layer [==================================================>] 119.8kB/119.8kB Loaded image: goharbor/harbor-migrator:v1.9.3 4bb3c8da2619: Loading layer [==================================================>] 50.3MB/50.3MB fa60bb5fba7f: Loading layer [==================================================>] 3.584kB/3.584kB 12a81f321c68: Loading layer [==================================================>] 3.072kB/3.072kB a94dcd551900: Loading layer [==================================================>] 2.56kB/2.56kB c684117da188: Loading layer [==================================================>] 3.072kB/3.072kB f14e11ea2c25: Loading layer [==================================================>] 3.584kB/3.584kB 2e2e439cb618: Loading layer [==================================================>] 12.29kB/12.29kB Loaded image: goharbor/harbor-log:v1.9.3 99ce145e19e6: Loading layer [==================================================>] 10.84MB/10.84MB Loaded image: goharbor/nginx-photon:v1.9.3 da7ad744c6fd: Loading layer [==================================================>] 16.4MB/16.4MB a03cee9d5ed3: Loading layer [==================================================>] 29.21MB/29.21MB f5f37ba098b1: Loading layer [==================================================>] 22.02kB/22.02kB c6e237d0effb: Loading layer [==================================================>] 51.85MB/51.85MB Loaded image: goharbor/notary-server-photon:v0.6.1-v1.9.3 01d39dbfbd65: Loading layer [==================================================>] 115.7MB/115.7MB 6d1186763503: Loading layer [==================================================>] 12.31MB/12.31MB 293c8dc3d8c6: Loading layer [==================================================>] 2.048kB/2.048kB d0ffe0bb8b6b: Loading layer [==================================================>] 48.13kB/48.13kB c9f0ab7d8bbb: Loading layer [==================================================>] 3.072kB/3.072kB 75c4044a879b: Loading layer [==================================================>] 12.36MB/12.36MB Loaded image: goharbor/clair-photon:v2.1.0-v1.9.3 b2329d5f99cf: Loading layer [==================================================>] 12.77MB/12.77MB 17c27eb4f7f8: Loading layer [==================================================>] 55.4MB/55.4MB 3c10f4815fc0: Loading layer [==================================================>] 5.632kB/5.632kB 5fb810768754: Loading layer [==================================================>] 36.35kB/36.35kB 376871497fae: Loading layer [==================================================>] 55.4MB/55.4MB Loaded image: goharbor/harbor-core:v1.9.3 2c38bb39e841: Loading layer [==================================================>] 12.77MB/12.77MB 20ef2473aa7f: Loading layer [==================================================>] 48.13MB/48.13MB Loaded image: goharbor/harbor-jobservice:v1.9.3 bc526ee3d965: Loading layer [==================================================>] 9.005MB/9.005MB d880cff24505: Loading layer [==================================================>] 3.072kB/3.072kB adc7407dd64d: Loading layer [==================================================>] 21.76MB/21.76MB aa1f551082be: Loading layer [==================================================>] 3.072kB/3.072kB 97bd8288c3d1: Loading layer [==================================================>] 8.661MB/8.661MB f184a9da0594: Loading layer [==================================================>] 30.42MB/30.42MB Loaded image: goharbor/harbor-registryctl:v1.9.3 [Step 2]: preparing environment ... prepare base dir is set to /root/harbor 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 [Step 3]: starting Harbor ... Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating redis ... done Creating harbor-portal ... done Creating registryctl ... done Creating registry ... done Creating harbor-db ... done Creating harbor-core ... done Creating harbor-jobservice ... done Creating nginx ... done ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://192.168.1.208. For more details, please visit https://github.com/goharbor/harbor . |
7、验证
至此安装完成,访问http://192.168.1.208验证,账号admin,密码whsir.com
补充:本文Harbor是http方式进行连接(想要使用https方式请自行更改harbor配置harbor.yml),由于docker默认是以https连接registry,所以通过docker连接Harbor时,需要更改/etc/docker/daemon.json配置文件,增加"insecure-registries": ["http://192.168.1.208"]参数。
原文链接:Docker私有仓库Harbor之安装部署,转载请注明来源!