apt 上的 DNS 无法在 docker 容器内工作,其他工作正常

apt 上的 DNS 无法在 docker 容器内工作,其他工作正常

我的一台在 Debian 10 上运行 OMV 5 的服务器上的 Docker 容器遇到了这个问题。

Temporary failure resolving

关于这个设置。我最近在两台 x86 和一台 ARM 服务器上安装了 OMV 5。问题仅出现在其中一台服务器上,而在主机操作系统内部 dns 似乎工作正常,我可以安装和升级软件包,但在 docker 容器中它根本不起作用。我尝试遵循几个指南,但到目前为止没有任何帮助。还恢复了镜像并重新安装了几次docker。此外,这些服务器具有相同的操作系统映像,只是进行了一些与磁盘相关的配置更改。我已经尝试过这个指南https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/和这个https://www.dedoimedo.com/computers/docker-container-no-network.html 在所有服务器上我都得到这个

root@mars:~# docker run busybox nslookup google.com
Server:         192.168.1.1
Address:        192.168.1.1:53

Non-authoritative answer:
Name:   google.com
Address: 172.217.20.174

*** Can't find google.com: No answer

它可以在两台服务器上运行(arm 和 x86):

root@venus:~# docker run -t -i ubuntu /bin/bash
root@9e4dce3d6ad9:/# apt update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [8273 B]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [60.9 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [4673 B]
Get:9 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB] 
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]                                                                                                                                                                                                                   
Get:11 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]                                                                                                                                                                                                             
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [31.6 kB]                                                                                                                                                                                                       
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [4673 B]                                                                                                                                                                                                      
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [104 kB]                                                                                                                                                                                                            
Get:15 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [2903 B]                                                                                                                                                                                                      
Fetched 13.6 MB in 10s (1389 kB/s)                                                                                                                                                                                                                                                            
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
root@9e4dce3d6ad9:/# 

但在 3rd(x86) 我得到了这个

root@mars:~# docker run -t -i ubuntu /bin/bash
root@173885bb1bfa:/# apt update
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

我的路由器运行的是 OpenWrt 19.07,我还重新启动它并删除 dhcp 租约。解决了安装后无法自动配置网络的问题。我还找到并启动了一个带有 X 和 VNC 的容器。在浏览器中 DNS 工作正常,但在 apt 中不行。 使用谷歌查看图像

我还使用 henet 隧道代理来获取 ipv6。

答案1

该问题与 OMV 安装 docker 和 portainer 时默认接收网关 IP 的某种错误有关。重新创建没有 portainer 的 Docker 存储解决了这个问题。

相关内容