zcbot/deploy/sandbox
caoqianming ae15a36e58 init.sh: 覆写 /etc/resolv.conf 绕过 docker embedded DNS
发现 user-defined bridge network 上 docker run --dns 是改 daemon 给 embedded
DNS(127.0.0.11)的上游 forward 目标,容器 /etc/resolv.conf 不变(仍是
nameserver 127.0.0.11)。腾讯云轻量等场景 daemon 探测 systemd-resolved 上游
失败 → embedded DNS 自身 forward 也跪 → --dns 8.8.8.8 救不了。

正确解:init.sh 启动时直接覆写 /etc/resolv.conf,完全绕过 embedded DNS。
- pool.py 把 --dns flag 换成 -e ZCBOT_DNS=8.8.8.8,114.114.114.114
- init.sh apply_resolv_conf 函数循环 echo "nameserver $ip" > /etc/resolv.conf
- /etc/resolv.conf 是 docker bind mount file(非 rootfs),--read-only 不挡,
  root 跑 init.sh 可写;--restart=no 容器生命周期内不被 docker 覆盖

iptables 127.0.0.11 ACCEPT 例外保留不动(无副作用,以备未来需要 service
discovery 等场景)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 12:03:24 +08:00
..
Dockerfile Stage C 收尾包:资源 yaml + 磁盘配额 + 网络放开 + 容器内源持久化 2026-05-27 08:35:53 +08:00
init.sh init.sh: 覆写 /etc/resolv.conf 绕过 docker embedded DNS 2026-05-27 12:03:24 +08:00