blu*_*onk 10 networking linux dns ubuntu docker
我已经安装docker在一台全新的 ubuntu 桌面 18.04 机器上,安装完成后我立即失去了主机中的互联网连接。更具体地说,我可以ping 8.8.8.8但我不能ping www.google.com。
重现错误的步骤如下:
编辑:
全新安装和我的情况之间最重要的区别是我的机器使用的是本地 DNS 服务器,该服务器在公司网络中172.17.100.3和172.17.100.70公司网络中具有固定地址。
从我到目前为止阅读,无论是问题来自NetworkManager的尝试管理docker0界面或 东西在泊坞窗安装过程中断裂systemd的决心能力。注意systemd-resolve 默认使用 127.0.0.53
到目前为止,我已经尝试了以下几点:
nameserver 8.8.8.8在/etc/resolv.conf作品resolv.conf。dnsmasq来自/etc/NetworkingManager.conf:我用这个解决方案,因为我在这里展示https://github.com/moby/moby/issues/36153,这表明在Ubuntu 16.04的同样的问题。我全新安装的 18.04 没有此行,因此此修复程序不再有效。NetworkManager完全删除,如https://docs.docker.com/install/linux/linux-postinstall/#dns-resolver-found-in-resolvconf-and-containers-cant-use-it但我不确定这是否与我的问题有关。我也不知道这是否会破坏其他东西。docker0 https://gist.github.com/lanrat/458066dbdeb460b9cef40dc2af639a24 的管理,但它不能解决我的问题到目前为止,唯一有效的方法是在 中对 google dns 服务器地址进行硬编码resolv.conf,在我看来这不是一种干净的方法。我还必须在启动时自动执行此过程,这是我不喜欢的。
如何在具有 docker 的开发机器中正确解决 NetworkingManager 问题?
我的默认resolv.conf有
nameserver 127.0.0.53
Run Code Online (Sandbox Code Playgroud)
并systemd-resolve --status返回(我与一位同事核对过,我们有相同的输出)
Global
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 4 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 3 (eno1)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 172.17.100.3
172.17.100.70
Link 2 (eno2)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Run Code Online (Sandbox Code Playgroud)
ifconfig docker0
bluesmonk@laptop:/etc/NetworkManager$ ifconfig docker0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:86:e0:f0:94 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Run Code Online (Sandbox Code Playgroud)
和状态 docker service
$ sudo service docker status
? docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-07-03 10:17:35 -04; 4min 52s ago
Docs: https://docs.docker.com
Main PID: 14992 (dockerd)
Tasks: 31
CGroup: /system.slice/docker.service
??14992 /usr/bin/dockerd -H fd://
??15015 docker-containerd --config /var/run/docker/containerd/containerd.toml
jul 03 10:17:32 laptop dockerd[14992]: time="2018-07-03T10:17:32.981563020-04:00" level=warning msg="Your kernel does not support swap memory limit"
jul 03 10:17:32 laptop dockerd[14992]: time="2018-07-03T10:17:32.981595408-04:00" level=warning msg="Your kernel does not support cgroup rt period"
jul 03 10:17:32 laptop dockerd[14992]: time="2018-07-03T10:17:32.981603807-04:00" level=warning msg="Your kernel does not support cgroup rt runtime"
jul 03 10:17:32 laptop dockerd[14992]: time="2018-07-03T10:17:32.982040899-04:00" level=info msg="Loading containers: start."
jul 03 10:17:34 laptop dockerd[14992]: time="2018-07-03T10:17:34.403909997-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used
jul 03 10:17:35 laptop dockerd[14992]: time="2018-07-03T10:17:35.083366302-04:00" level=info msg="Loading containers: done."
jul 03 10:17:35 laptop dockerd[14992]: time="2018-07-03T10:17:35.458766295-04:00" level=info msg="Docker daemon" commit=9ee9f40 graphdriver(s)=overlay2 version=18.03.1-ce
jul 03 10:17:35 laptop dockerd[14992]: time="2018-07-03T10:17:35.458857295-04:00" level=info msg="Daemon has completed initialization"
jul 03 10:17:35 laptop dockerd[14992]: time="2018-07-03T10:17:35.470042819-04:00" level=info msg="API listen on /var/run/docker.sock"
jul 03 10:17:35 laptop systemd[1]: Started Docker Application Container Engine.
lines 1-20/20 (END)
Run Code Online (Sandbox Code Playgroud)
与我的机器有关
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:43:51 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:42:00 2018
OS/Arch: linux/amd64
Experimental: false
Run Code Online (Sandbox Code Playgroud)
码头工人信息:
docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-23-generic
Operating System: Ubuntu 18.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 31.38GiB
Name: bluesmonk-ubuntu
ID: FRUH:57KI:POWV:EAHH:CY6Y:J3UH:OWBH:AIYF:BONF:DH4Q:5Y2P:RZ6T
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Run Code Online (Sandbox Code Playgroud)
关于发行版
$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"
NAME="Ubuntu"
VERSION="18.04 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Run Code Online (Sandbox Code Playgroud)
可能相关
谢谢!
ps:我在 docker 论坛中用相同的信息打开了一个问题https://forums.docker.com/t/cant-access-internet-after-installing-docker-in-a-fresh-ubuntu-18- 04-机/53416
lar*_*sks 10
所以这是你的问题:
Docker 已将范围分配172.17.0.1/16给您的docker0界面。这包括从172.17.0.1到 的所有地址172.17.255.255。您会注意到此范围包括您的 DNS 服务器(172.17.100.3和172.17.100.70)。您遇到的是路由问题:
每当您的主机需要访问您的 DNS 服务器时,它都会发现它在同一网络上已经有一个接口 ( docker0),因此它会尝试使用该接口路由数据包……这当然无处可去,这就是您的 DNS 停止工作的原因.
Docker 没有一个简单的机制来从它的自动选择过程中排除地址范围,所以你可能需要做两件事来解决这个问题:
首先,docker0在您的/etc/docker/daemon.json. 使用任何不会与您的内部网络发生冲突的网络。例如:
{
"bip": "172.31.0.1/16"
}
Run Code Online (Sandbox Code Playgroud)
您需要重新启动 Docker。
接下来,为了防止 Docker 为用户定义的网络(您显式使用docker network create或隐式使用,例如docker-composeor docker stack ...)选择相同的网络范围,请创建一个新网络,然后永远不要使用它:
docker network create --subnet 172.17.0.0/16 --config-only do_not_use
Run Code Online (Sandbox Code Playgroud)
这应该既可以解决您的问题,又可以防止它在将来再次出现。
更新
Docker 实际上在如何影响 Docker 在“docker 网络创建”期间选择的网络地址范围中记录了一种可以说是更好的实现方式?.
这需要在您的系统上设置持久静态路由,这在 Linux 发行版之间有所不同。