【发布时间】:2015-10-24 03:37:20
【问题描述】:
如果我想构建我的 Dockerfile,它无法连接到网络或至少 DNS:
Sending build context to Docker daemon 15.95 MB
Sending build context to Docker daemon
Step 0 : FROM ruby
---> eeb85dfaa855
Step 1 : RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
---> Running in ec8cbd41bcff
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/InRelease
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/Release.gpg Could not resolve 'httpredir.debian.org'
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/Release.gpg Could not resolve 'httpredir.debian.org'
W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg Could not resolve 'security.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package build-essential
INFO[0001] The command "/bin/sh -c apt-get update -qq && apt-get install -y build-essential libpq-dev" returned a non-zero code: 100
但如果我通过docker run 运行完全相同的命令,它就可以工作:
docker run --name="test" ruby /bin/sh -c 'apt-get update -qq && apt-get install -y build-essential libpq-dev'
有人知道,为什么docker build 不起作用?我已经在 StackOverflow 上尝试了所有与 DNS 相关的提示,例如使用 --dns 8.8.8.8 等启动 docker。
提前致谢
【问题讨论】:
-
我应该提一下,几周前完全相同的 Dockerfile 已经工作了。
-
我遇到了同样的问题。你解决过这个问题吗?
-
不.. 不在这台机器上:(