总结—Harbor仓库部署和使用问题集锦

栏目: 编程工具 · 发布时间: 5年前

内容简介:在实验环境:harbor服务器系统:CentOS Linux release 7.4.1708 (Core)

前言

离线手动部署 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)

问题集锦

1、docker配置文件没生效,引起的push镜像失败,报错10.0.0.101:443: getsockopt: connection refused

问题描述:

在test101机器刚刚部署好harbor的时候,push镜像失败了,报“Get https://10.0.0.101/v1/_ping : dial tcp 10.0.0.101:443: getsockopt: connection refused”

[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,但是这行内容也没有加载成功):

总结—Harbor仓库部署和使用问题集锦

解决方法:

再次重新启动了docker服务,使之重新加载配置文件

[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]#

2、端口问题引起的pull镜像报错Get https://10.0.0.101/v1/_ping : dial tcp 10.0.0.101:443: getsockopt: connection refused

问题描述:

把harbor端口默认的80端口修改为1180,然后打了个测试镜像上去,但是在test102机器pull镜像的时候失败了,报错如下:

[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”:

总结—Harbor仓库部署和使用问题集锦

然后重启了docker服务:

[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端口:

[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”这条命令!

3、push镜像失败,报denied: requested access to the resource is denied

问题描述:

部署好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]#

4、360浏览器设置问题引起的harbor仓库访问异常

问题描述:

部署好harbor仓库之后,发现浏览器访问界面出不来,一直处于这样的状态:

总结—Harbor仓库部署和使用问题集锦

原因分析:

后来发现因为这台机器上只有360浏览器,存在模式的区别,现在用的是默认的兼容模式,所以界面出不来,并非服务的问题。

解决办法:

把浏览器换成极速模式就好了:

总结—Harbor仓库部署和使用问题集锦

为了避免这种不必要的问题,最好不要用360这样的浏览器,最好使用谷歌浏览器


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Big Red Fez

The Big Red Fez

Seth Godin / Free Press / 2002-01-15 / USD 11.00

YOUR WEB SITE IS COSTING YOU MONEY. IT'S ALSO FILLED WITH SIMPLE MISTAKES THAT TURN OFF VISITORS BEFORE THEY HAVE A CHANCE TO BECOME CUSTOMERS. According to marketing guru Seth Godin, a web s......一起来看看 《The Big Red Fez》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器