【发布时间】:2017-06-15 08:19:14
【问题描述】:
我一直在关注官方文档here。
我的Dockerfile、app.py和requirements.txt与教程中给出的相同。
当我尝试使用 docker build -t friendlyhello . 构建我的 Docker 映像时,当 docker 运行 RUN pip install -r requirements.txt 部分时出现以下错误:
连接被“NewConnectionError(”中断后重试(Retry(total=4, connect=None, read=None, redirect=None)):无法建立新连接:[Errno -2] 名称或服务未知',)': /simple/flask/
我已经查看了this 并尝试了所有建议的解决方案,但似乎都不起作用。
提前致谢。
编辑 1:我的 requirements.txt
Flask
Redis
完整的输出
Sending build context to Docker daemon 4.608 kB
Step 1/7 : FROM python:2.7-slim
---> 4ba53c70eb04
Step 2/7 : WORKDIR /app
---> Using cache
---> bebf675fc3bd
Step 3/7 : ADD . /app
---> Using cache
---> 435299812b68
Step 4/7 : RUN pip install -r requirements.txt
---> Running in 97465239272f
Collecting Flask (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f29c8b33910>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f29c8bb9f90>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f29c9aa69d0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f29c9aa6190>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f29c9aa6510>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Could not find a version that satisfies the requirement Flask (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for Flask (from -r requirements.txt (line 1))
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
编辑 2:我发现我的公司使用了一个特定的 DNS,我可以使用它来解析 docker run --dns [DNS] busybox nslookup google.com
【问题讨论】:
-
请添加您的
requirements.txt和完整的输出。 -
我在我的服务器上尝试过同样的东西,它正在工作。试图了解您的设置,您可以从您的容器 ping 到 google.com 吗?运行这个命令“docker run busybox nslookup google.com”
-
@Here_2_learn 似乎没有按预期工作。我最终收到了
nslookup: can't resolve 'google.com'的消息。 -
@Here_2_learn 请参阅编辑 2。
-
确保您的公司 dns 位于
/etc/resolv.conf或配置 docker 守护程序以指向它!
标签: python docker dockerfile