我无法从在 Ubuntu 上运行的 Docker 容器内部解析任何公共主机名:
e4e6b07dafb0:/# traceroute google.com
traceroute: bad address 'google.com
尝试使用 google 公共 dns 服务器运行容器,但没有帮助:
docker run --dns 8.8.8.8 -it docker.io/jonlabelle/network-tools:latest bash
e4e6b07dafb0:/# traceroute google.com
traceroute: bad address 'google.com'
e4e6b07dafb0:/# nslookup google.com
;; communications error to 8.8.8.8#53: timed out
;; communications error to 8.8.8.8#53: timed out
;; communications error to 8.8.8.8#53: timed out
;; no servers could be reached
nslookup google.com 8.8.8.8
也尝试在容器内运行,但没有成功。
docker 主机上的解析有效。
Docker 守护进程详细信息如下:
docker version
Client: Docker Engine - Community
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:32:12 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:32:12 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.24
GitCommit: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
runc:
Version: 1.1.9
GitCommit: v1.1.9-0-gccaecfc
docker-init:
Version: 0.19.0
GitCommit: de40ad0
如何解决此错误?