harbor 多端口_总结—Harbor仓库部署和使用问题集锦

本文总结了Harbor仓库在CentOS 7.4环境下部署遇到的问题,包括docker配置文件未生效导致push镜像失败、端口修改后pull镜像错误、权限拒绝问题以及360浏览器访问异常等,提供了详细的解决方法。
摘要由CSDN通过智能技术生成

在离线手动部署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,但是这行内容也没有加载成功):

f7d451a9fec6698ad2f32d02dee681d0.png

解决方法:

再次重新启动了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”:

758b73d3905b54b11653dca0d10de62d.png

然后重启了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仓库之后,发现浏览器访问界面出不来,一直处于这样的状态:

abf940c49a5b8a744cd85eb54a731f42.png

原因分析:

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

解决办法:

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

5362425f3ee35c69a8cd4fe8ea00cea4.png

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值