搭建好harbor服务器后,从另一台机登录时遇到的问题

harbor服务器环境:192.168.0.10
在另一台装有docker的机器上尝试登录harbor机器,遇到两个问题,这台机器的ip是:192.168.0.7

第一次登录:

docker login -u admin -p Harbor12345 192.168.0.10

结果报错了:

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://192.168.0.10/v2/: x509: cannot validate certificate for 192.168.0.10 because it doesn't contain any IP SANs

网上查到的说法是,不能用ip来登录,必须要用域名,相关的域名在安装harbor时,已使用域名来生成证书了。
于是要修改harbor.cfg配置文件,修改成配置文件,还得运行一下harbor目录下的prepare文件
./prepare
运行完后,重启harbor:首先docker-compose down,接着启动harbor:docker-compose up -d
运行docker-compose命令,必须把目录切换到harbor目录才能运行。

经过这一步后,进行第二次登录:

docker login -u admin -p Harbor12345 harbor.xxx.com

其中harbor.xxx.com是用来生成证书的域名
结果第二次报错:

 WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://harbor.xxx.com/v2/: x509: certificate signed by unknown authority

网上的说法是:因为自签名的原因,参考:https://segmentfault.com/a/1190000008615155

解决的方案如下:
1 把在harbor服务器生成的ca证书harbor.xxx.com.crt放到那台要登录的机器上
scp harbor.xxx.com.crt 192.168.0.7:/home
2 在192.168.0.7机器上,把crt证书放到/etc/docker/certs.d/harbor.xxx.com目录下(注意:该目录一开始是不存在的,连certs.d都不存在,手动建)
mkdir -p /etc/docker/certs.d/harbor.xxx.com
然后,重启docker
systemctl restart docker

Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@k8etc-node2 ~]# systemctl daemon-reload
[root@k8etc-node2 ~]# systemctl restart docker

再来登录,(要注意:harbor.xxx.com需在/etc/hosts文件加上ip,域名映射)

 [root@k8etc-node2 ~]# docker login -u admin -p Harbor12345 harbor.xxx.com
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
Are you sure you want to proceed? [y/N] y
Login Succeeded

/etc/hosts

 [root@k8etc-node2 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.10 harbor.xxx.com
[root@k8etc-node2 ~]#

你可能感兴趣的:(搭建好harbor服务器后,从另一台机登录时遇到的问题)