场景
在一台Centos 7中。通过docker-compose 启动了Harbor服务。
同时在该服务器中,提前启动了Iptables 服务器,设置的规则为:
Harbor所在的机器IP为:192.168.77.17
现在通过网页可以访问到Harbor,如:http://192.168.77.17:80/
但是在 192.168.77.17 中,通过 docker login -u admin -p Harbor12345 192.168.77.17:80 却一直报错。报错信息为:
[root@k8s-master harbor]# docker login -u admin -p Harbor12345 192.168.77.17:80WARNING! Using --password via the CLI is insecure. Use --password-stdin.Error response from daemon: Get http://192.168.77.17:80/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
原因
应该是docker改变中了在IPtables中设置的规则,所以导致不能访问docker暴露的端口。
但是这里有个问题:我在网页可以中访问到,但是就是不能在192.168.77.17的命令行不能登录,但是其他服务器是可以访问的。
解决办法
service iptables save
参考资料
Centos7修改iptables规则并开机永久生效两种方式: https://blog.csdn.net/Victor2code/article/details/105768946?spm=1001.2101.3001.4242
iptables配置docker服务端口访问限制: https://zhuanlan.zhihu.com/p/457250110
