- 在线安装:从Docker Hub下载Harbor相关镜像,因此安装软件包非常小
- 离线安装:安装包包含部署的相关镜像,因此安装包比较大
- OVA安装程序:当用户具有vCenter环境时,使用此安装程序,在部署OVA后启动Harbor
离线安装docker-compse工具 [root@docker01 ~]# ls docker-compose.1.25.0.tar.gz harbor-offline-installer-v2.0.2.tgz [root@docker01 ~]# tar zxpf docker-compose.1.25.0.tar.gz -C /usr/local/bin/ [root@docker01 ~]# cd /usr/local/bin/ [root@docker01 bin]# ls docker-compose-Linux-x86_64 [root@docker01 bin]# mv docker-compose-Linux-x86_64 docker-compose [root@docker01 bin]# chmod +x /usr/local/bin/docker-compose [root@docker01 bin]# docker-compose -v docker-compose version 1.25.0, build 0a186604 //下载依赖包 [root@docker bin]# yum -y install yum-utils device-mapper-persistentdata lvm22、harbor离线模式
直接在百度搜 harbor进官网 harbor的部署方式,有在线和离线两种方式,考虑到网速原因,这里我们采用离线下载方式。
wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.4.tgz
[root@docker01 ~]# tar -zxf harbor-offline-installer-v2.0.2.tgz -C /usr/local/ [root@docker01 ~]# cd /usr/local/harbor/ [root@docker harbor]# ls common.sh harbor.v2.0.2.tar.gz harbor.yml.tmpl install.sh LICENSE prepare [root@docker01 harbor]# cp harbor.yml.tmpl harbor.yml [root@docker01 harbor]# vim harbor.yml
修改hostname=IP
注释掉https,我们就用http就可以了。如果要用https需要开启nginx sll为on
// 修改完配置文件后,在的当前目录执行./install.sh,Harbor服务就会根据当期目录下的docker-compose.yml开始下载依赖的镜像,检测并按照顺序依次启动,并且注意,harbor默认使用的是80端口,最好确认是否有冲突,或者也可以在docker-compose.yml中修改对应的端口
[root@docker01 harbor]# systemctl daemon-reload [root@docker01 harbor]# systemctl restart docker [root@docker01 harbor]# ./install.sh查看和监控
[root@docker01 harbor]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES af0d3f823c92 goharbor/registry-photon:v2.0.2 "/home/harbor/entryp…" About a minute ago Up 2 seconds (health: starting) 5000/tcp registry ce229f6b7e37 goharbor/harbor-db:v2.0.2 "/docker-entrypoint.…" About a minute ago Up 2 seconds (health: starting) 5432/tcp harbor-db a357025287c1 goharbor/harbor-log:v2.0.2 "/bin/sh -c /usr/loc…" About a minute ago Up 2 seconds (health: starting) 127.0.0.1:1514->10514/tcp harbor-log harbor-logharbor使用 //在执行此命令是一定要在模板目录下!
[root@docker01 harbor]# pwd /usr/local/harbor [root@docker harbor]# docker-compose start Starting log ... done Starting registry ... done Starting registryctl ... done Starting postgresql ... done Starting portal ... done Starting redis ... done Starting core ... done Starting jobservice ... done Starting proxy ... done [root@docker01 harbor]# netstat -anput | grep 80 tcp 0 0 127.0.0.1:51580 127.0.0.1:1514 ESTABLISHED 6286/dockerd tcp 0 0 127.0.0.1:1514 127.0.0.1:51580 ESTABLISHED 6474/docker-proxy tcp6 0 0 :::80 :::* LISTEN 8355/docker-proxy访问:http://192.168.1.10/harbor docker client的设置 //因为docker不支持https的原因,我们也需要将docker的配置文件进 行更改。
[root@docker02 /]# vim /usr/lib/systemd/system/docker.service ..... ExecStart=/usr/bin/dockerd --insecure-registry 192.168.1.10 .... [root@docker02 /]# systemctl daemon-reload [root@docker02 /]# systemctl restart docker客户端登录与上传镜像
[root@docker02 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos7 latest 7e6257c9f8d8 5 months ago 203MB [root@docker02 ~]# docker tag centos7:latest 192.168.1.10/test/centos:7 //重新打个标签 [root@docker02 ~]# docker login -u admin -p Harbor12345 192.168.1.10 //登录 WARNING! Using --password via the CLI is insecure. Use --password-stdin. 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@docker02 ~]# docker push 192.168.1.10/test/centos //上传 The push refers to repository [192.168.1.10/test/centos] 613be09ab3c0: Pushed 7: digest: sha256:fe2347002c630d5d61bf2f28f21246ad1c21cc6fd343e70b4cf1e5102f8711a9 size: 529 [root@docker ~]# docker images //查看harbor仓库所有镜像 REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.1.10:5000/httpd-iso latest 740e9757f71d 4 hours ago 567MB
命令总结
#推送之前先登录Harbor docker login docker login registry.test.myop.com -u admin -p Harbor12345 提示success登录成功 查看自己有哪些镜像;docker images 把需要上传到Harbor的镜像运行如下命令就可以了 #镜像打标签 docker tag 镜像名:标签 私服地址/仓库项目名/镜像名:标签 #推送到私服 docker push 私服地址/仓库项目名/镜像名:标签 #从私服拉取镜像 docker pull 私服地址/仓库项目名/镜像名:标签 也可以在web界面复制下载路径 #通过compose关闭harbor容器服务 docker-compose down