Docker 容器内没有互联网连接

Sas*_*nko 1 ubuntu internet-connection docker

我无法在任何 Docker 容器内执行任何需要互联网连接的命令。

作品:

docker run ubuntu /bin/echo 'Hello world'
Run Code Online (Sandbox Code Playgroud)

不起作用:

docker run ubuntu apt-get update

Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'archive.ubuntu.com'
Run Code Online (Sandbox Code Playgroud)

pip与和类似ping

我使用的是 Ubuntu 16.04,没有使用防火墙或企业代理服务器,并尝试重新启动 Docker。不使用 docker-machine 或 boot2docker。

Sas*_*nko 6

在超级用户上得到答案:

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d
Run Code Online (Sandbox Code Playgroud)

“它将迫使 docker 重新创建网桥并重新初始化所有网络规则”