请教一个 Docker/Traefik 的网路问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
liuliuliuliu
0.01D
V2EX    Docker

请教一个 Docker/Traefik 的网路问题

  •  
  •   liuliuliuliu
    PRO
    87 天前 1385 次点击
    这是一个创建于 87 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我当前有服务 A 和 B ,以及 Traefik ,他们三个都跑在同一台机器的 docker 里。
    A 和 B 都通过 Traefik 进行了反代以及绑定了域名 A.example.comB.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 他也没搞明白……
    6 条回复    2025-09-21 20:11:02 +08:00
    fitme
        1
    fitme  
       87 天前
    感觉问题不够清晰,细节可以多描述点。有个问题如果只是 A 访问 B 走 docker dns 即可不需要转一圈再回来
    momocraft
        2
    momocraft  
       87 天前
    容器 A 内 traceroute 公网 IP 的结果是怎样的?
    liuliuliuliu
        3
    liuliuliuliu  
    OP
    PRO
       86 天前
    @momocraft

    traceroute to 公网 IP (公网 IP), 30 hops max, 46 byte packets
    1 * * *
    2 * * *
    3 * * *
    4 * * *
    5 * * *
    6 * * *
    7 * * *
    8 * * *
    9 * * *

    奇怪为什么不通
    julyclyde
        4
    julyclyde  
       85 天前
    A 和 B 的域名对应 IP 相同吗?
    liuliuliuliu
        5
    liuliuliuliu  
    OP
    PRO
       85 天前
    @julyclyde 相同的
    julyclyde
        6
    julyclyde  
       84 天前
    @liuliuliuliu 哦,你的意思是,俩域名相同的 IP ,一个能访问 443 端口,另一个域名不能访问 443 端口?
    我只能说:我主观选择不相信你的描述了
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3803 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 05:14 PVG 13:14 LAX 21:14 JFK 00:14
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86