来自守护进程的错误响应:rpc 错误:代码 = Unavailable 描述 = 连接错误:描述 = "传输:拨号时出错:拨号 tcp:在 127.0.0.11:53 上查找 tasks.manager:没有这样的主机"
Error response from daemon: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp: lookup tasks.manager on 127.0.0.11:53: no such host"
ID: docker/network-not-connecting-to-swarm
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.6 | active | — | — | — |
| Swarm 1.2.0 | active | — | — | — |
| Linux 5.15.0 | active | — | — | — |
根因分析
Docker Swarm 服务无法解析内部 DNS 名称 'tasks.manager',因为 overlay 网络未正确附加,或者由于 DNS 解析失败导致 swarm 管理器节点不可达。
English
A Docker Swarm service cannot resolve the internal DNS name 'tasks.manager' because the overlay network is not properly attached or the swarm manager node is unreachable due to DNS resolution failure.
官方文档
https://docs.docker.com/engine/swarm/networking/解决方案
-
确保服务已附加到 overlay 网络:'docker service update --network-add my-overlay myservice'。然后使用 'docker service ps myservice' 验证,并在容器内使用 'docker exec <container> nslookup tasks.manager' 检查 DNS 解析。
-
在管理器节点上重新初始化 swarm:'docker swarm leave --force' 然后 'docker swarm init --advertise-addr <manager-ip>'。使用新令牌重新加入工作节点。
无效尝试
常见但无效的做法:
-
Restart the Docker daemon on all nodes
70% 失败
Restarting does not fix the overlay network configuration or DNS resolver issue; the error reappears.
-
Manually add 'tasks.manager' to /etc/hosts inside the container
80% 失败
The tasks.manager name is dynamically resolved by Swarm's internal DNS; static entries conflict with overlay network routing.
-
Set '--dns 8.8.8.8' in docker service create
85% 失败
External DNS cannot resolve internal Swarm names like tasks.manager; this breaks service discovery.