Debian

apt 上的 DNS 不能在 docker 容器中工作,其他的工作

  • May 25, 2020

我的一台在 Debian 10 上執行 OMV 5 的伺服器上的 Docker 容器存在這個問題。

Temporary failure resolving

關於這個設置。我最近在兩台 x86 和一台 ARM 伺服器上安裝了 OMV 5。問題僅出現在其中一台伺服器上,而在主機 os 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:/# 

但在 3 日(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 中卻不行。 使用工作Google查看圖片

我還使用 henet 隧道代理來獲取 ipv6。

該問題與 OMV 如何安裝 docker 和 portainer 預設接收網關 IP 的某種錯誤有關。重新創建不帶搬運工的 docker 儲存解決了這個問題。

引用自:https://unix.stackexchange.com/questions/585129