首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docker课程教程,python pip失败

Docker课程教程,python pip失败
EN

Stack Overflow用户
提问于 2017-10-11 17:48:45
回答 1查看 1.6K关注 0票数 4

我正在遵循在https://docker-curriculum.com/教程,以产生我的第一个码头形象。在第2.4节中,我们将了解如何使用基本映像python:3-onbuild配置一个简单的Dockerfile,该文件将自动运行pip并安装来自requirements.txt的依赖项。

问题是,当我试图构建坞时,这些包根本无法加载:

代码语言:javascript
运行
复制
mgitt@mgpc:~/workspace/docker-curriculum/flask-app$ docker build -t prakhar1989/catnip .
Sending build context to Docker daemon  8.704kB
Step 1/3 : FROM python:3-onbuild
# Executing 3 build triggers...
Step 1/1 : COPY requirements.txt /usr/src/app/
 ---> Using cache
Step 1/1 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Running in 74c4e94fa1ba
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 0x7fc6592831d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283cc0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283208>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283470>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283ba8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 --no-cache-dir -r requirements.txt' returned a non-zero code: 1
mgitt@mgpc:~/workspace/docker-curriculum/flask-app$ 

我已经看过这个stackoverflow solution了。这些答案似乎解决了许多人的问题,即无法与域名服务器( DNS )连接,但重置停靠程序或将DNS添加到/etc/dhcp/dhclient.conf对我没有任何帮助。

我已经安装了Docker版本的17.09.0-ce,并且正在Ubuntu 16.04上运行,有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-11 21:58:35

如果您正在处理代理。码头集装箱根本无法上网的可能性很大。

您可以通过运行

代码语言:javascript
运行
复制
$ docker run -it busybox sh
/ # ping google.com

如果它挂了你知道你有问题。现在我们必须找到您的主机用来连接到internet的网络接口。ipconfig会给你一个名字列表,无论哪个用来连接互联网,都是你的IFACENAME。现在运行:

代码语言:javascript
运行
复制
$ nmcli dev list | grep 'IP4.DNS'                    # Ubuntu <= 14
$ nmcli device show IFACENAME | grep IP4.DNS         # Ubuntu >= 15

这将列出代理服务器所在的IP_ADDRESS。可能有一个以上,只需使用第一个。创建具有以下内容的文件/etc/docker/daemon.json

代码语言:javascript
运行
复制
{
    "dns": ["IP_ADDRESS", "8.8.8.8"]
}

最后,

代码语言:javascript
运行
复制
$ sudo service docker restart

现在您应该能够从容器中进行ping操作。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46694556

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档