<p>你的问题来自Docker没有使用正确的DNS服务器。
你可以用三种不同的方法修复它:</p>
<h2>一。将Google DNS添加到本地配置</h2>
<p>修改/etc/resolv.conf并在末尾添加以下行</p>
<p><code># Google IPv4 nameservers
nameserver 8.8.8.8
nameserver 8.8.4.4
</code></p>
<p>如果要添加其他DNS服务器,请查看<a href="https://wiki.archlinux.org/index.php/Resolv.conf" rel="noreferrer">here</a>。</p>
<p>不过,这种变化不会是永久性的(请参见<a href="https://superuser.com/questions/677343/how-to-make-name-server-address-permanent-in-etc-resolv-conf">this thread</a>)。使之永久:
<code>$ sudo nano /etc/dhcp/dhclient.conf
</code>
取消注释并编辑带有前置域名服务器的行:
<code>prepend domain-name-servers 8.8.8.8, 8.8.4.4;</code></p>
<p>重新启动dhclient:<code>$ sudo dhclient</code>。</p>
<h2>2。修改Docker配置</h2>
<p>作为<a href="https://docs.docker.com/installation/ubuntulinux/#configure-a-dns-server-for-use-by-docker" rel="noreferrer">explained in the docs</a>:</p>
<blockquote>
<p>Systems that run Ubuntu or an Ubuntu derivative on the desktop typically use 127.0.0.1 as the default nameserver in /etc/resolv.conf file.</p>
<p>To specify a DNS server for use by Docker :</p>
</blockquote>
<pre><code>1. Log into Ubuntu as a user with sudo privileges.
2. Open the /etc/default/docker file for editing :
$ sudo nano /etc/default/docker
3. Add the following setting for Docker.
DOCKER_OPTS="--dns 8.8.8.8"
4. Save and close the file.
5. Restart the Docker daemon :
$ sudo systemctl restart docker
</code></pre>
<h2>三。运行Docker时使用参数</h2>
<p>运行docker时,只需添加以下参数:<code>--dns 8.8.8.8</code></p>