我在Ubuntu 16.04上运行docker-ce。在构建我的自定义应用程序时,它失败了,因为它无法安装Flask,这是Python应用程序所必需的。
我支持我的组织代理,所以我也使用了内联代理。但它仍然失败了。
Dockerfile:
RUN pip install -r requirements.txt \
--proxy https://10.70.52.146:3128 \
--trusted-host pypi.python.org
requirements.txt:
Flask
Redis
输出:
Step 7/10 : RUN pip install -r requirements.txt --proxy https://10.70.52.146:3128 --trusted-host pypi.python.org<br/>
---> Running in 3d92822e4d79<br/>
Collecting Flask (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, u'EOF occurred in violation of protocol (_ssl.c:661)'),)': /packages/7f/e7/08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4b/Flask-1.0.2-py2.py3-none-any.whl<br/>
Could not install packages due to an EnvironmentError:<br/>HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/7f/e7/08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4b/Flask-1.0.2-py2.py3-none-any.whl (Caused by SSLError(SSLEOFError(8, u'EOF occurred in violation of protocol (_ssl.c:661)'),))
The command '/bin/sh -c pip install -r requirements.txt --proxy http://10.70.52.146:3128 --trusted-host pypi.python.org' returned a non-zero code: 1
此错误指的是什么?
答案 0 :(得分:0)
将HTTP_PROXY
和HTTPS_PROXY
环境变量设置为构建参数可以解决您的问题。
Dockerfile:
FROM python:3.6
ADD requirements.txt requirements.txt
RUN pip install -r requirements.txt
构建命令:
docker build --build-arg HTTP_PROXY=https://10.70.52.146:3128 --build-arg HTTPS_PROXY=https://10.70.52.146:3128 .
在Dockerfile之外设置代理地址也是一种更好的做法,因为它允许您从组织网络外部重用此Dockerfile。