我有一个Docker桥接网络,其中连接了2个容器:
网络具有以下配置:
[
{
"Name": "mynetwork",
"Id": "f94f76533b065d39515b65d20b8645c22617be51ec9335fcfad8ce707ca48841",
"Created": "2019-02-20T17:17:29.029434324+01:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "10.1.0.0/16",
"Gateway": "10.1.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"Containers": {
"c8084141e36c756710cbfa020f664127f234e407986362331ab127d415c9b074": {
"Name": "nodeContainer",
"EndpointID": "e25f8797c1b7488d7c3810d8f38c4b3dea6b9f19f17558a164b710015fdd9e1a",
"MacAddress": "02:42:0a:01:00:03",
"IPv4Address": "10.1.0.3/16",
"IPv6Address": ""
},
"f9c582d031515f4bba910286118df806a6a2b04a36917234eca09fdf335d4457": {
"Name": "flaskContainer",
"EndpointID": "fbf053f97acc7b9491c536966b640862d366d1599fbfb400915cd8bc26b04f6a",
"MacAddress": "02:42:0a:01:00:02",
"IPv4Address": "10.1.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
通常,这两个容器进行通信(nodeContainer
向http://flaskContainer:5000
发出请求),但是在设置了不同的Subnet
和Gateway
之后(由于外部网络限制,此容器停止工作)。
特别是,我收到类似ETIMEDOUT 10.1.0.2:3333
的错误。这使我认为该地址已正确解析,但是由于某种原因,没有答案(实际上flaskContainer
什么也没记录)。
作为其他信息:
docker exec flaskContainer curl flaskContainer
docker exec nodeContainer curl nodeContainer
显然不起作用(Failed to connect to flaskContainer port 80
)。
docker exec flaskContainer curl flaskContainer:5000
docker exec nodeContainer curl nodeContainer:3333
正确给出结果。
docker exec flaskContainer curl nodeContainer:3333
docker exec nodeContainer curl flaskContainer:5000
超时。
您是否知道可能是什么原因?我该如何解决? 谢谢