我尝试从一个docker容器ssh到互联网,但它没有任何错误就卡住了。我在详细模式下运行ssh,这就是结果:
root@bac91c5282c7:/opt# ssh -v git@git.foo.com -i /root/.ssh/id_rsa
OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to git.foo.com [xx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
我的问题与此question类似,但问题是由于Gateway
和IPAddress
为空,因此网桥配置不正确。但就我而言,一切似乎都是正确的。我也可以telnet到任何远程机器上我想要的任何端口。该问题与ssh
具体相关。
foo@bar:~/code$ ip addr | grep "docker"
7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
inet 172.17.0.1/16 scope global docker0
docker network:
foo@bar:~/code$ docker network ls
NETWORK ID NAME DRIVER SCOPE
e8f23bd035df bridge bridge local
b1eca300de29 host host local
aa7945003010 none null local
c6ac46615046 code_default bridge local
docker inspect
的输出:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "77e0a4431cdd656605591d2cff40c0a68d811cb700066f047b9d4a241d4634be",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/77e0a4431cdd",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "90c7ff3ddeab7ac6287d56fb6aaec81252a8f15c95fb65921f7872bd7bf8eb70",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "5c0c33b6892d197a30fff6d806999698705615c62fd35229e9477e9658783548",
"EndpointID": "90c7ff3ddeab7ac6287d56fb6aaec81252a8f15c95fb65921f7872bd7bf8eb70",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
}
值得一提的是,此问题仅在特定服务器上发生。我已经在我的笔记本电脑或VPS上测试了这个容器,但没有遇到任何问题。
知道如何解决这个问题吗?