泊坞窗构建没有网络,但码头工人跑了 [英] Docker build has no network, but docker run has

查看:281
本文介绍了泊坞窗构建没有网络,但码头工人跑了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要建立我的Dockerfile,它无法连接到网络,或至少DNS:

If I want to build my Dockerfile, it can't connect to the network or at least 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

但是,如果我通过泊坞窗运行它的工作原理运行完全相同的命令:

But if I run exactly the same command via docker run it works:

docker run --name="test" ruby /bin/sh -c 'apt-get update -qq && apt-get install -y build-essential libpq-dev'

有谁有一个想法,为什么泊坞窗构建不起作用?我已经尝试了所有DNS StackOverflow上相关的窍门,就像--dns 8.8.8.8等开始泊坞窗。

Does anybody have an idea, why docker build does not work? I have tried all DNS related tipps on StackOverflow, like starting docker with --dns 8.8.8.8 etc.

在此先感谢

推荐答案

试图运行我的码头工人,版本也未能 apt-get的升级完全相同的错误。我使用泊坞窗机在Mac OSX和一个简单的泊坞窗机重启默认解决了这个问题。不知道什么最初引起这一点,虽然。

My docker build also failed while trying to run apt-get upgrade with the exact same errors. I was using docker-machine on Mac OSX and a simple docker-machine restart default solved this issue. No idea what initially caused this, though.

这篇关于泊坞窗构建没有网络,但码头工人跑了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆