docker
network_error
ai_generated
true
错误:无法解析主机:registry-1.docker.io;临时名称解析失败
ERROR: could not resolve host: registry-1.docker.io; Temporary failure in name resolution
ID: docker/resolv-conf-dns-resolution-timeout
90%修复率
88%置信度
1证据数
2023-11-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.6 | active | — | — | — |
| Docker 25.0.1 | active | — | — | — |
| Ubuntu 22.04 | active | — | — | — |
根因分析
Docker 守护进程或容器 DNS 配置指向了无法工作或不可达的 DNS 服务器,通常由于公司 VPN 或 /etc/resolv.conf 配置错误。
English
Docker daemon or container DNS configuration points to a non-functional or unreachable DNS server, often due to corporate VPN or misconfigured /etc/resolv.conf.
官方文档
https://docs.docker.com/config/daemon/#dns-settings解决方案
-
Set DNS in Docker daemon config: edit /etc/docker/daemon.json and add 'dns': ['8.8.8.8', '1.1.1.1'], then restart docker.
-
Use --dns flag per container: docker run --dns 8.8.8.8 your_image
-
If using VPN, configure Docker to use host's DNS via /etc/docker/daemon.json: 'dns': ['<vpn_dns_ip>', '8.8.8.8']
无效尝试
常见但无效的做法:
-
sudo resolvectl flush-caches
80% 失败
Flushing DNS cache on host does not affect Docker's internal DNS resolution.
-
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
60% 失败
Adding a public DNS like 8.8.8.8 to /etc/resolv.conf may be overwritten by Docker or network manager.
-
sudo systemctl restart docker
70% 失败
Restarting docker daemon without fixing DNS config will repeat the same issue.