软件简介 Harbor是由VMware公司中国团队为企业用户设计的Registryserver开源项目,包括了权限管理(RBAC)、LDAP、审计、管理界面、自我注册、HA等企业必需的功能,同时针对中国用户的特点,设计镜像复制和中文支持等功能。基于角色的访问控制用户与Docker镜像仓库通过项目进行组织管理,一个用户可以对多个镜像仓库在同一命名空间(project)里有不同的权限。镜像复制镜像可以在多个Registry实例中复制(同步)。尤其适合于负载均衡,高可用,混合云和多云的场景。图形化用户界面用户可以通过浏览器来浏览,检索当前Docker镜像仓库,管理项目和命名空间。ADLDAP支持Harbor可以集成企业内部已有的ADLDAP,用于鉴权认证管理。审计管理所有针对镜像仓库的操作都可以被记录追溯,用于审计管理。国际化已拥有英文、中文、德文、日文和俄文的本地化版本。更多的语言将会添加进来。RESTfulAPIRESTfulAPI提供给管理员对于Harbor更多的操控,使得与其它管理软件集成变得更容易。部署简单提供在线和离线两种安装工具,也可以安装到vSphere平台(OVA方式)虚拟设备。使用注意事项HTTP与HTTPS 由于私有环境没有https通讯证书,所以已下部署均是http协议。docker默认是不支持http的,需要做如下修改。 〔rootclouddocker〕vietcdockerdaemon。json 将其中insecureregistries地址换成自己环境真实的即可。 { execopts:〔native。cgroupdriversystemd〕, logdriver:jsonfile, logopts:{ maxsize:100m }, storagedriver:overlay2, storageopts:〔 overlay2。overridekernelchecktrue 〕, registrymirrors:〔 https:docker。mirrors。ustc。edu。cn, https:registry。dockercn。com 〕, insecureregistries:〔 xxx。xxx。xxx。xxx:8082 〕, graph:datadockerlib }部署部署前工作 Harbor官方文档 Harbor下载地址关闭防火墙和selinux 〔rootlocalhostharbor〕systemctldisablenowfirewalld Removedetcsystemdsystemmultiuser。target。wantsfirewalld。service。 Removedetcsystemdsystemdbusorg。fedoraproject。FirewallD1。service。 〔rootlocalhostharbor〕systemctlstopnowfirewalld 〔rootlocalhostharbor〕catetcselinuxconfig SELINUXdisabled修改这一行 修改完之后重启 〔rootlocalhostharbor〕reboot 〔rootlocalhostharbor〕setenforce0 setenforce:SELinuxisdisabled下载harbor包配置docker加速器 〔rootlocalhost〕vimetcdockerdaemon。json { registrymirrors:〔https:kgdsiwq8。mirror。aliyuncs。com〕 } 重新加载docker服务 〔rootlocalhost〕systemctldaemonreload 〔rootlocalhost〕systemctlrestartdocker 查看加速器配置情况 〔rootlocalhost〕dockerinfo 。。。。。。以上省略 Experimental:false InsecureRegistries: 127。0。0。08 RegistryMirrors: https:kgdsiwq8。mirror。aliyuncs。com加速器配置成功 LiveRestoreEnabled:false单节点部署 (其中hostname可以直接配置为IP地址) 解压harbor包到usrlocal目录下 〔rootlocalhost〕tarxfharborofflineinstallerv2。6。1。tgzCusrlocal 〔rootlocalhost〕cdusrlocal 〔rootlocalhostlocal〕ls bingamesincludelib64sbinsrc etcharborliblibexecshare 〔rootlocalhostlocal〕cdharbor 〔rootlocalhostharbor〕ls LICENSEharbor。v2。6。1。tar。gzinstall。sh common。shharbor。yml。tmplprepare 设置主机名 〔rootlocalhostharbor〕hostnamectlsethostnamenode01 〔rootlocalhostharbor〕bash 〔rootnode1harbor〕hostname node01 〔rootnode01harbor〕cpharbor。yml。tmplharbor。yml 〔rootnode01harbor〕vimharbor。yml DONOTuselocalhostor127。0。0。1,becauseHarborneedstobeaccessedbyexternalclients。 hostname:node01添加主机名 httpsrelatedconfig https:注释掉证书,不使用证书就需要注释 httpsportforharbor,defaultis443 port:443注释 Thepathofcertandkeyfilesfornginx certificate:yourcertificatepath注释 privatekey:yourprivatekeypath注释 harboradminpassword:Harbor12345默认的登录密码 以上这些需要修改,其余保持默认 添加主机映射 〔rootlocalhostharbor〕vimetchosts 127。0。0。1localhostlocalhost。localdomainlocalhost4localhost4。localdomain4 ::1localhostlocalhost。localdomainlocalhost6localhost6。localdomain6 192。168。91。137node01 测试能否ping通node01主机 〔rootlocalhostharbor〕pingnode01 PINGnode1。example。com(192。168。91。137)56(84)bytesofdata。 64bytesfromnode1。example。com(192。168。91。137):icmpseq1ttl64time0。044ms 64bytesfromnode1。example。com(192。168。91。137):icmpseq2ttl64time0。033ms 加载离线镜像 〔rootlocalhostharbor〕dockerloadiharbor。v2。6。1。tar。gz 〔rootlocalhostharbor〕。prepare 启动脚本进行安装 〔rootlocalhostharbor〕。install。sh 〔Step0〕:checkingifdockerisinstalled。。。 Note:dockerversion:20。10。12 〔Step1〕:checkingdockercomposeisinstalled。。。 Note:dockercomposeversion:1。29。2 〔Step2〕:loadingHarborimages。。。 。。。。。。安装过程省略 Harborhasbeeninstalledandstartedsuccessfully。 安装完成会自动启动很多容器 〔rootnode1harbor〕dockerps CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES 3daa18aedde3goharborharborjobservice:v2。3。5harborentrypoint。5secondsagoUp4seconds(health:starting)harborjobservice 67cda2a01e08goharbornginxphoton:v2。3。5nginxgdaemonof5secondsagoUp4seconds(health:starting)0。0。0。0:808080tcp,:::808080tcpnginx 388f512bcfe1goharborharborcore:v2。3。5harborentrypoint。6secondsagoUp4seconds(health:starting)harborcore b4e7fefa599egoharborharbordb:v2。3。5dockerentrypoint。7secondsagoUp5seconds(health:starting)harbordb 9201662bba92goharborredisphoton:v2。3。5redisserveretcr7secondsagoUp5seconds(health:starting)redis 42368cf0e78bgoharborregistryphoton:v2。3。5homeharborentryp7secondsagoUp5seconds(health:starting)registry ed564a1e593bgoharborharborregistryctl:v2。3。5homeharborstart。7secondsagoUp5seconds(health:starting)registryctl daa189f31bc3goharborharborportal:v2。3。5nginxgdaemonof7secondsagoUp5seconds(health:starting)harborportal 8ac96968e301goharborharborlog:v2。3。5binshcusrloc7secondsagoUp6seconds(health:starting)127。0。0。1:151410514tcpharborlog 安装完成之后会多两个文件,一个common,一个dockercompose。yml 〔rootlocalhostharbor〕lsusrlocalharbor LICENSEdockercompose。ymlharbor。yml。tmpl commonharbor。v2。3。5。tar。gzinstall。sh common。shharbor。ymlprepare 〔rootnode1harbor〕ssantl StateRecvQSendQLocalAddress:PortPeerAddress:PortProcess LISTEN01280。0。0。0:220。0。0。0: LISTEN0128127。0。0。1:15140。0。0。0: LISTEN01280。0。0。0:800。0。0。0: LISTEN0128〔::〕:22〔::〕: LISTEN0128〔::〕:80〔::〕:4。5harbor网页操作 使用系统账号登录 http:xxx。xxx。xxx。xxx:8082harborprojectsadminHarbor12345仓库管理功能 定义Registry实例,可以是公网的也可以是私有的,比如网易163的https:hub。c。163。com 和dockerHUB 添加完成后,点击测试连接即可。项目功能 项目可以作为私有的镜像仓库管理,也可以代理共有环境的镜像信息。推送私有环境的镜像,也需要先建立项目方可。如下展示的是将公共镜像私有化。公共镜像打tag dockertaggrafanagrafana:9。2。1xxx。xxx。xxx。xxx:8082abugrafana:9。2。1查看镜像 〔rootclouddocker〕dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE 10。21。5。30:8081abucentosuserd8506ac3842d20hoursago193MB centosuserd8506ac3842d20hoursago193MB grafanagrafana9。2。146e73c2b7a353daysago347MB镜像推送 〔rootclouddocker〕dockerpushxxx。xxx。xxx。xxx:8082abugrafana:9。2。1 Thepushreferstorepository〔xxx。xxx。xxx。xxx:8082abugrafana〕 7cb09c9a4372:Pushed f0be059d864b:Pushed ef88b45a119f:Pushed 3b2b7c569a4c:Pushed 839b0b40ab56:Pushed adff21d3bcca:Pushed 1e2c29677398:Pushed 8675ede87d30:Pushed 34d5ebaa5410:Pushed 9。2。1:digest:sha256:33be3c2d3f457192a284777e24ae6bd264598896451c01ec2c7f329da4707af2size:2203管理态 harbor网页可以看到abu状态想多了一个镜像信息。代理镜像 新建项目时选择镜像代理即可,项目名称很重要,需要在平常使用的镜像前缀加上。 未使用代理的时候 〔rootclouddocker〕dockerpullbitnamiprometheus:latest latest:Pullingfrombitnamiprometheus 0796bf144e3f:Pullcomplete f2e46fdc7dbf:Pullcomplete 16a37524c720:Pullcomplete 71419d3ad358:Pullcomplete a2ed6d2d4643:Pullcomplete b3a121d40da9:Pullcomplete 2ee758bc629a:Pullcomplete af7e41fdf0e4:Pullcomplete Digest:sha256:145fa39d958e0546b1c154bb82215cec753c7268ba447b093d2490a556d73bd3 Status:Downloadednewerimageforbitnamiprometheus:latest docker。iobitnamiprometheus:latest 使用harbor代理共有环境 〔rootbogoncedar〕dockerpullxxx。xxx。xxx。xxx:8082dockerhubbitnamiprometheus:latest latest:Pullingfromdockerhubbitnamiprometheus 1d8866550bdd:Pullcomplete 7a956b97b95f:Pullcomplete Digest:sha256:35d02ae6b542d7980df579f21953431e61bf096f05d74496361d8cd80a046461 Status:Downloadednewerimageforxxx。xxx。xxx。xxx:8082dockerhubbitnamiprometheus:latest xxx。xxx。xxx。xxx:8082dockerhubbitnamiprometheus:latest