尝试在自己的房屋中构建Docker映像时,我发现了一个奇怪的问题,尽管我不确定它是否与浏览器相关,或者仅与网络相关。
所以这就是我得到的。我试图在Dockerfile中运行此命令。
RUN apt-get update -qq && \
apt-get install -y build-essential \
libpq-dev \
postgresql-client
Run Code Online (Sandbox Code Playgroud)
等待片刻后,该过程会输出类似以下内容的内容。
W: Failed to fetch http://deb.debian.org/debian/dists/jessie/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/jessie/Release.gpg Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/Release.gpg Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Run Code Online (Sandbox Code Playgroud)
奇怪的是,如果我在办公室网络中尝试过此操作,则不会发生这种情况。然后,如果我尝试绑定到手机数据网络,也不会发生这种情况。
我尝试http://deb.debian.org/debian/dists/jessie/InRelease在浏览器中打开,它显示404。我尝试通过多个网络使用Tor浏览器,它也显示404。
docker映像基于ruby:2.3.1。
更新
我试图使用房屋供应商提供的DNS 203.142.82.222。
sudo docker run --dns 203.142.82.222 busybox nslookup google.com
Run Code Online (Sandbox Code Playgroud)
这样解决
Server: 203.142.82.222
Address 1: 203.142.82.222 dns-cache1.biz.net.id
Name: google.com
Address 1: 2404:6800:4003:808::200e sin10s07-in-x0e.1e100.net
Address 2: 117.102.117.245
Address 3: 117.102.117.251
Address 4: 117.102.117.212
Run Code Online (Sandbox Code Playgroud)
但是后来我更改为/etc/default/docker文件并添加了它。
DOCKER_OPTS="--dns 203.142.82.222 --dns 203.142.84.222"
Run Code Online (Sandbox Code Playgroud)
重新启动docker之后sudo service docker restart,我再次尝试,但仍然无法正常工作。
sudo service docker restart
sudo docker run busybox nslookup google.com
Server: 8.8.8.8
Address 1: 8.8.8.8
nslookup: can't resolve 'google.com'
Run Code Online (Sandbox Code Playgroud)
Luí*_*usa 10
我刚刚处理了构建cartoza/postgis图像的这个问题,它源于debian:stable. 发生这种情况是因为无法从此网络访问某些流行的公共 DNS,例如:
$ nslookup duckduckgo.com 8.8.8.8
;; connection timed out; no servers could be reached
Run Code Online (Sandbox Code Playgroud)
可能最简单的方法是直接指示 Docker 使用网络可用的 DNS。首先验证他们的地址:
$ nmcli dev show | grep 'IP4.DNS'
IP4.DNS[1]: 10.91.3.31
IP4.DNS[2]: 10.90.3.31
IP4.DNS[3]: 10.90.7.14
Run Code Online (Sandbox Code Playgroud)
将它们添加到名为 的新配置文件中daemon.json:
$ sudo pico /etc/docker/daemon.json
并插入以下内容:
{
"dns": ["10.91.3.31", "10.90.3.31", "10.90.7.14"]
}
Run Code Online (Sandbox Code Playgroud)
然后重启服务:
$ sudo service docker restart
Run Code Online (Sandbox Code Playgroud)
/etc/default/docker 文件仅在使用“upstart”和“SysVInit”的系统上使用,而不在使用 systemd 的系统上使用。
因此,不要使用 /etc/default/docker。它仅由 upstart 使用,自 16.04 起 Ubuntu 不再使用它。
使用 /etc/docker/daemon.json,其记录如下: https: //docs.docker.com/engine/reference/commandline/dockerd/#/linux-configuration-file
在那里你可以配置你的dns
| 归档时间: |
|
| 查看次数: |
18516 次 |
| 最近记录: |