我在从服务器上的 docker 容器请求多个外部资源时遇到问题
这是 docker-compose 文件(没什么异常):
services:
nodejs:
image: image_name
volumes:
- ./config/config.json:/app/config/config.json
labels:
- "traefik.frontend.rule=my_domain.com"
- "traefik.enable=true"
- "traefik.port=8080"
restart: always
networks:
- int_network
networks:
int_network:
external: true
问题是容器内部的几个请求因超时而死亡,例如
/app # curl https://google.com --max-time 15 -v
* Trying 74.125.205.138:443...
* Connected to google.com (74.125.205.138) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* Operation timed out after 15000 milliseconds with 0 out of 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 5000 milliseconds with 0 out of 0 bytes received
但是如果我尝试使用 http 访问 google.com - 一切都很好
即使我无法访问 https://google.com,我也可以访问 https://yahoo.com - 所以只有少数网站受到影响。
在主机上一切正常。
docker inspect
用于网络:
{
"Name": "int_network",
"Id": "f1147fd7d4cdc63f82aaa6bc9b71c79713f9e590d7c3cb8a2aa07339456413e2",
"Created": "2020-07-16T07:42:41.949623342Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
// Containers list
},
"Options": {},
"Labels": {}
}
]
有什么建议吗?也许是 SSL 问题?
答案 0 :(得分:0)
这是 MTU 问题。创建新的档案网络解决了问题