我当前有服务 A 和 B ,以及 Traefik ,他们三个都跑在同一台机器的 docker 里。
A 和 B 都通过 Traefik 进行了反代以及绑定了域名 A.example.com 和 B.example.com 并进行了公网解析
现在的问题是:
容器 A 内无法通过域名访问到 B ,curl -v B.example.com 时返回如下:
```
* Host B.example.com:443 was resolved.
* IPv6: (none)
* IPv4: (服务器的公网 IP)
* Trying (服务器的公网 IP):443...
* connect to (服务器的公网 IP) port 443 from 172.22.0.6 port 53088 failed: Operation timed out
* Failed to connect to B.example.com port 443 after 130394 ms: Could not connect to server
* closing connection #0
curl: (28) Failed to connect to B.example.com port 443 after 130394 ms: Could not connect to server
```
宿主机执行 curl -v B.example.com 是没问题的。
我没太想明白为什么容器内无法通过公网域名访问?
问了 cursor 他也没搞明白……
A 和 B 都通过 Traefik 进行了反代以及绑定了域名 A.example.com 和 B.example.com 并进行了公网解析
现在的问题是:
容器 A 内无法通过域名访问到 B ,curl -v B.example.com 时返回如下:
```
* Host B.example.com:443 was resolved.
* IPv6: (none)
* IPv4: (服务器的公网 IP)
* Trying (服务器的公网 IP):443...
* connect to (服务器的公网 IP) port 443 from 172.22.0.6 port 53088 failed: Operation timed out
* Failed to connect to B.example.com port 443 after 130394 ms: Could not connect to server
* closing connection #0
curl: (28) Failed to connect to B.example.com port 443 after 130394 ms: Could not connect to server
```
宿主机执行 curl -v B.example.com 是没问题的。
我没太想明白为什么容器内无法通过公网域名访问?
问了 cursor 他也没搞明白……
