【问题标题】:Docker failed to fetch http://deb.debian.org/debian/dists/jessie/InRelease [closed]Docker 未能获取 http://deb.debian.org/debian/dists/jessie/InRelease [关闭]
【发布时间】:2017-10-20 04:25:30
【问题描述】:

我在尝试在家中构建 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

更新

我尝试使用我的房屋提供商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"

重启dockersudo 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'

【问题讨论】:

标签: docker debian


【解决方案1】:

/etc/default/docker 文件仅在使用“upstart”和“SysVInit”的系统上使用,而不在使用 systemd 的系统上使用。

文件顶部也提到了这一点: https://github.com/docker/docker/blob/44fe8cbbd174b5d85d4a063ed270f6b9d2279b70/contrib/init/sysvinit-debian/docker.default#L1

所以,不要使用 /etc/default/docker。它仅供新贵使用,自 16.04 以来 Ubuntu 不再使用它。

使用 /etc/docker/daemon.json,记录在这里:https://docs.docker.com/engine/reference/commandline/dockerd/#/linux-configuration-file

在那里你可以配置你的dns

【讨论】:

    【解决方案2】:

    我刚刚处理了构建cartoza/postgis 图像的问题,该图像源于debian:stable。发生这种情况是因为无法从该网络访问某些流行的公共 DNS,例如:

    $ nslookup duckduckgo.com 8.8.8.8
    ;; connection timed out; no servers could be reached
    

    可能最简单的解决方法是直接指示 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
    

    将它们添加到名为 daemon.json 的新配置文件中:

    $ sudo pico /etc/docker/daemon.json

    并插入以下内容:

    {
        "dns": ["10.91.3.31", "10.90.3.31", "10.90.7.14"]
    }
    

    然后重启服务:

    $ sudo service docker restart
    

    【讨论】:

    • Luis,您能否进一步解释一下 docker 上缺少什么来检测或使用可用的 DNS?比如,没有 docker 服务可以自动发现和填充 docker/daemon.json?
    【解决方案3】:

    一个原因可能是你的代理没有在 Docker 文件中设置,在 Dockerfile 中添加这两行:

    ENV http_proxy "http://www-proxy.x.com:80"
    ENV https_proxy "http://www-proxy.x.com:80"
    

    请在此处更新您的代理。 并且不要写

    ENV HTTP_PROXY "http://www-proxy.x.com:80"
    

    因为 env 变量区分大小写

    【讨论】:

      【解决方案4】:

      添加

      ENV http_proxy "http://www-proxy.x.com:80"
      ENV https_proxy "http://www-proxy.x.com:80"
      

      在我的 Docker 文件末尾为我工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-08-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-08
        相关资源
        最近更新 更多