在离线手动部署docker镜像仓库——harbor仓库(一) 和离线手动部署docker镜像仓库——harbor仓库(二)的实验中,遇到一些harbor仓库部署的问题,在此作个小结。
实验环境:
harbor服务器系统:CentOS Linux release 7.4.1708 (Core)
harbor服务器IP:10.0.0.101(test101)
harbor版本:v1.5.0
docker版本:1.13.1
使用了另外一台机器作pull和push镜像测试:10.0.0.102(test102)nginx
在test101机器刚刚部署好harbor的时候,push镜像失败了,报“Get https://10.0.0.101/v1/_ping: dial tcp 10.0.0.101:443: getsockopt: connection refused”web
[root@test101 nginx]# docker push 10.0.0.101/test/bigdatacenter:latest The push refers to a repository [10.0.0.101/test/bigdatacenter] Get https://10.0.0.101/v1/_ping: dial tcp 10.0.0.101:443: getsockopt: connection refused [root@test101 nginx]#
是由于配置文件里面配置的--insecure-registry=10.0.0.101这一行配置没有生效(修改了配置以后,有重启docker,可是这行内容也没有加载成功):docker
再次从新启动了docker服务,使之从新加载配置文件json
[root@test101 harbor]# systemctl daemon-reload #重启docker以前,先执行了这个步骤,很重要 [root@test101harbor]# systemctl restart docker
而后测试登陆harbor仓库,就OK了:浏览器
[root@test101 harbor]# docker login 10.0.0.101 Username: admin Password: Login Succeeded
再push镜像就成功了:服务器
[root@test101 harbor]# docker push 10.0.0.101/test/bigdatacenter:latest The push refers to a repository [10.0.0.101/test/bigdatacenter] df9d7f53cb5b: Pushed ab0926f7eb13: Pushed 24a30430d761: Pushed 20dd87a4c2ab: Layer already exists 78075328e0da: Layer already exists 9f8566ee5135: Layer already exists latest: digest: sha256:07c467b4f8c6cfa306484bd060721fb621ddb1fd43f528ef5a0df1157d8bd853 size: 1573 [root@test101 harbor]#
把harbor端口默认的80端口修改成1180,而后打了个测试镜像上去,可是在test102机器pull镜像的时候失败了,报错以下:tcp
[root@test102 ~]# docker pull 10.0.0.101/test/bigdatacenter:latest Trying to pull repository 10.0.0.101/test/bigdatacenter ... Get https://10.0.0.101/v1/_ping: dial tcp 10.0.0.101:443: getsockopt: connection refused
1)想起来test102机器上的docker的配置文件没有修改,因而在 /etc/sysconfig/docker 加上了“--insecure-registry=10.0.0.101:1180”:
而后重启了docker服务:ide
[root@test102 ~]# systemctl restart docker [root@test102 ~]#
再从新pull镜像,发现报错不同了:测试
[root@test102 ~]# docker pull 10.0.0.101/test/bigdatacenter:latest Trying to pull repository 10.0.0.101/test/bigdatacenter ... Pulling repository 10.0.0.101/test/bigdatacenter Error while pulling image: Get http://10.0.0.101/v1/repositories/test/bigdatacenter/images: dial tcp 10.0.0.101:80: getsockopt: connection refused
2)报错dial tcp 10.0.0.101:80: getsockopt: connection refused,是由于镜像名称里面没有加上1180端口,就默认去80端口找镜像了,因而在命令里面加上了1180端口:ui
[root@test102 ~]# docker pull 10.0.0.101:1180/test/bigdatacenter:latest Trying to pull repository 10.0.0.101:1180/test/bigdatacenter ... Get https://10.0.0.101:1180/v1/_ping: http: server gave HTTP response to HTTPS client #关于这个报错,网上有不少文章说是关于docker和harbor之间的交互存在一个http和https之间的问题,建议改/etc/docker/daemon.json 。可是按照网上的方法试了,改了/etc/docker/daemon.json 以后,docker服务起不来,无法解决。最后仍是尝试使用systemctl daemon-reload+systemctl restart docker两条命令解决了问题 [root@test102 ~]#
3)加上1180端口以后,报错不同了,因而试着像上一个问题同样,尝试执行systemctl daemon-reload命令。从新载入 systemd,扫描新的或有变更的单元,而后再重启docker:
[root@test102 ~]# systemctl daemon-reload [root@test102 ~]# systemctl restart docker
再pull镜像,发现就成功了!
[root@test102 ~]# docker pull 10.0.0.101:1180/test/bigdatacenter:latest Trying to pull repository 10.0.0.101:1180/test/bigdatacenter ... latest: Pulling from 10.0.0.101:1180/test/bigdatacenter 53478ce18e19: Pull complete d1c225ed7c34: Pull complete c6724ba0c09a: Pull complete de3b8705ee9f: Pull complete c091a284f068: Pull complete 010503dbdd2d: Pull complete Digest: sha256:ce823873379c519a583756783923dd160473a60fcf78dfd869e8b33f5198f237 Status: Downloaded newer image for 10.0.0.101:1180/test/bigdatacenter:latest [root@test102 ~]#
注意,问题1和2说明,修改了docker的配置文件 /etc/sysconfig/docker以后,重启docker服务,文件不必定生效了,若是发现没生效,别忘了“systemctl daemon-reload”这条命令!
部署好harbor仓库的时候,push镜像失败了,报denied: requested access to the resource is denied
[root@test101 harbor]# docker push 10.0.0.101:1180/test/bigdatacenter:latest The push refers to a repository [10.0.0.101:1180/test/bigdatacenter] d7393e4babfa: Preparing d8db36d925b6: Preparing 93fc2863a9fb: Preparing 20dd87a4c2ab: Preparing 78075328e0da: Preparing 9f8566ee5135: Waiting denied: requested access to the resource is denied
遇到这种状况,登陆一下harbor仓库,登陆成功,就OK了。
关于缘由和解决方法,在网上查了,说法不一,也有不少其余的方法,可是没有试过,就试着登陆了一下,而后问题就解决了,部署过程当中遇到好几回这个问题,都是这样解决的。当换了用户名/密码/端口/域名什么的,在push镜像的时候就可能会出现这个问题。
[root@test101 harbor]# docker login 10.0.0.101:1180 #登陆一下就行了 Username: admin Password: Login Succeeded
而后再从新push镜像,就成功了
[root@test101 harbor]# docker push 10.0.0.101:1180/test/bigdatacenter:latest The push refers to a repository [10.0.0.101:1180/test/bigdatacenter] d7393e4babfa: Pushed d8db36d925b6: Pushed 93fc2863a9fb: Pushed 20dd87a4c2ab: Pushed 78075328e0da: Pushed 9f8566ee5135: Pushed latest: digest: sha256:63a86f231cf0415fe02ac11e31b00a959563ff3e264955c7c0236bd398b1c775 size: 1573 [root@test101 harbor]#
部署好harbor仓库以后,发现浏览器访问界面出不来,一直处于这样的状态:
后来发现由于这台机器上只有360浏览器,存在模式的区别,如今用的是默认的兼容模式,因此界面出不来,并不是服务的问题。
把浏览器换成极速模式就行了:
为了不这种没必要要的问题,最好不要用360这样的浏览器,最好使用谷歌浏览器
测试在rancher2.0上部署一个harbor仓库的服务到服务器上,发现拉取镜像失败,报错repository does not exist or may require ‘docker login’:
由于harbor仓库的项目访问级别设置成了私有,因此rancher-server和agent服务器都访问不到,所以报错没法拉取镜像。
由于在服务器上测试手动pull镜像,是测试的公开项目里面的镜像,因此没有发现该问题:
将harbor上面项目的访问级别设置为公开,就行了
在另外一次使用rancher2.0测试部署服务的时候,服务器上拉取了harbor仓库的web镜像,可是拉取镜像一直失败,报错以下:
看到这个熟悉的错误信息,立刻查看docker配置文件,发现harbor的地址多写了个http://
去掉配置文件的http:// 而后重启docker服务便可:
而后重启docker服务,从新部署,恢复正常: