在我家中尝试构建docker镜像时,我发现了一些奇怪的问题,虽然我不确定它是否与浏览器或网络问题相关.
所以这就是我得到的.我试图在我的Dockerfile中运行此命令.
RUN apt-get update -qq && \
apt-get install -y build-essential \
libpq-dev \
postgresql-client
等了片刻之后,有点过程输出这样的东西.
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.
奇怪的是,如果我在我的办公室网络中尝试过这种情况,这种情况就不会发生.然后,如果我试图绑定到我的手机数据网络,这也不会发生.
我尝试在浏览器中打开http://deb.debian.org/debian/dists/jessie/InRelease,它显示404.我尝试通过几个网络使用Tor浏览器,它也显示404.
docker镜像基于ruby:2.3.1.
UPDATE
我试图使用我的房屋提供商203.142.82.222提供的DNS.
sudo docker run --dns 203.142.82.222 busybox nslookup google.com
这解决了
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
但后来我改为/ etc / default / docker文件并添加了这个.
DOCKER_OPTS="--dns 203.142.82.222 --dns 203.142.84.222"
我重新启动docker sudo服务docker重新启动后,我再次尝试但它仍然无法正常工作.
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'
最佳答案 / etc / default / docker文件仅在使用“upstart”和“SysVInit”的系统上使用,而不是在使用systemd的系统上使用.
这也在文件的顶部提到:
https://github.com/docker/docker/blob/44fe8cbbd174b5d85d4a063ed270f6b9d2279b70/contrib/init/sysvinit-debian/docker.default#L1
所以,不要使用/ etc / default / docker.它仅由upstart使用,自16.04以来Ubuntu不使用它.
使用/etc/docker/daemon.json,这里记录:https://docs.docker.com/engine/reference/commandline/dockerd/#/linux-configuration-file
在那里你可以配置你的DNS