我按照https://docker-curriculum.com/中的教程生成我的第一个Docker镜像。在第2.4节中,我们将学习如何使用基本映像python:3-onbuild
来配置一个简单的Dockerfile,它将自动运行pip并安装requirements.txt
的依赖关系。Docker课程教程,python pip失败
的问题是,当我尝试建立搬运工,包装简单地加载失败:
[email protected]:~/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
[email protected]:~/workspace/docker-curriculum/flask-app$
我已经采取了看看这个stackoverflow solution。这些答案似乎已经解决了许多人无法与域名服务器(DNS)连接的问题,但重置码头或添加DNS到/etc/dhcp/dhclient.conf
没有为我做任何事情。
我已经安装了Docker版本17.09.0-ce
并且在Ubuntu 16.04
上运行,有什么想法?
@JanezKuhar这似乎不是问题,因为我正在拉一个'用户图像',它就像克隆某人的存储库。我也尝试了你的解决方案,这导致了相同的结果 – Max
错误信息表明尝试访问https://pypi.python.org/pypi时出现连接错误。您正在构建图像的机器是否可以连接到该网站? – jwodder
不,我不能。本质上问题是我无法连接到服务器,因为我的机器找不到正确的DNS。但在SO解决方案中尝试解决方案后,我仍然无法连接 – Max