python - RUN pip install:确认 ssl 证书时出现问题:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败
问题描述
跟着 [GitHub][1] 的实验室了解更多关于 Docker 容器的知识,我在这个问题中感受到了:
No matching distribution found for Flask==0.10.1 (from -r /usr/src/app/requirements.txt (line 1))
Could not fetch URL https://pypi.python.org/simple/flask/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726) - skipping```
[1]: https://github.com/docker/labs/blob/master/beginner/chapters/webapps.md
解决方案
问题与我位于 BlueCoat(一种防火墙)后面的网络中有关,该网络检查并隐藏了几乎来自我的桌面和 Internet 的通信。
在谷歌搜索后,我发现忽略证书问题的命令:
只需将其添加到我的 dockerfile
--trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org
# our base image
FROM alpine:3.5
# Install python and pip
RUN apk add --update py2-pip
# install Python modules needed by the Python app
COPY requirements.txt /usr/src/app/
RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org --no-cache-dir -r /usr/src/app/requirements.txt
# copy files required for the app to run
COPY app.py /usr/src/app/
COPY templates/index.html /usr/src/app/templates/
# tell the port number the container should expose
EXPOSE 5000
# run the application
CMD ["python", "/usr/src/app/app.py"]
推荐阅读
- angularjs - 检查函数是否成功执行茉莉花
- python - OpenPyXL:是否可以在 Excel 工作表中创建下拉菜单?
- reactjs - 如何在reactjs中获取远程定位的图像大小
- sql - ORA-01790: 表达式必须与对应的表达式 LISTAGG 具有相同的数据类型
- vue.js - 使用 Vue 处理递归组件中的插槽
- python - 如何从结果中创建 python 列表
- groovy - 如何从groovy中当前包的上一级导入
- php - Woocommerce 评级未显示在新的自定义主题中
- r - R数据框:每组(另一列)替换第一个值(一列)
- ruby - 块内定义的方法属于哪个类?