【发布时间】:2017-10-11 17:48:45
【问题描述】:
我正在按照https://docker-curriculum.com/ 中的教程制作我的第一个 Docker 映像。在第 2.4 节中,我们学习了如何使用基础镜像 python:3-onbuild 配置一个简单的 Dockerfile,它将自动运行 pip 并从 requirements.txt 安装依赖项。
问题是当我尝试构建 docker 时,包根本无法加载:
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) 的问题,但重置 docker 或将 DNS 添加到/etc/dhcp/dhclient.conf 对我没有任何帮助。
我安装了 Docker 版本 17.09.0-ce 并在 Ubuntu 16.04 上运行,有什么想法吗?
【问题讨论】:
-
@JanezKuhar 这似乎不是问题,因为我正在拉
User image,这就像克隆某人的存储库。我也尝试了您的解决方案,这导致了相同的结果 -
错误消息显示尝试访问pypi.python.org/pypi 时出现连接错误。您正在构建映像的机器可以连接到该站点吗?
-
不,我不能。本质上问题是我无法连接到服务器,因为我的机器找不到正确的 DNS。但是在尝试了SO方案中的方案后,还是无法连接
-
你在代理后面运行吗?
-
在 Firefox 中,我设法找到
Use system proxy settings已启用。我想这意味着我的整个系统都使用了代理