RUN pip安装:确认ssl证书时出现问题:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败

时间:2019-05-14 13:29:27

标签: python docker ssl

在[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

1 个答案:

答案 0 :(得分:0)

问题与以下事实有关:我位于BlueCoat(一种防火墙)后面的网络中,该网络检查并隐藏了来自台式机和Internet的几乎所有通信。

在Google搜索失败后,我发现了忽略证书问题的命令:

只需将其添加到我的dockerfile --trusted-host pypi.org --trusted-host pypi.python.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 --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"]