本站教程收集整理的这篇文章主要介绍了python – 构建Docker镜像时的InsecurePlatformWarning,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。
我在构建Docker镜像时收到此警告:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:79:
InsecureplatformWarning: A true SSLContext object is not available.
This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
For more @R_772_4036@ion,see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
几个来源(如InsecureplatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately)说,pip install pyopenssl ndg-httpsclient pyasn1将解决这个问题.但是一旦pip尝试安装pyopenssl,我就会收到警告.
这是我的Dockerfile:
FROM ubuntu:14.04
# Install packages
RUN apt-get update && apt-get install -y \
git \
libMysqLclient-dev \
MysqL-server \
Nginx \
python-dev \
python-MysqLdb \
python-setuptools \
supervisor \
vim
RUN easy_install pip
# Handle urllib3 InsecureplatformWarning
RUN apt-get install -y libffi-dev libssl-dev
RUN pip install pyopenssl ndg-httpsclient pyasn1
# ...more
似乎在运行pip:http://github.com/pypa/pip/issues/2681时会出现此警告,但在安装pyopenssl ndg-httpsclient pyasn1时,使用python请求时不会收到警告.
例如,如果我构建这个Dockerfile:
FROM ubuntu:14.04
# Install packages
RUN apt-get update && apt-get install -y \
git \
libMysqLclient-dev \
MysqL-server \
Nginx \
python-dev \
python-MysqLdb \
python-setuptools \
supervisor \
vim
RUN easy_install pip
RUN pip install requests
然后在容器内运行:
root@b2759f79f947:/# python
Python 2.7.6 (default,Jun 22 2015,17:58:13)
[GCC 4.8.2] on linux2
Type "Help","copyright","credits" or "license" for more @R_772_4036@ion.
>>> import requests
>>> url = "https://www.digicert.com/"
>>> r = requests.get(url)
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:100: InsecureplatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more @R_772_4036@ion,see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecureplatformWarning
如你所见,我得到了警告.
但是如果我在Dockerfile中添加这些行:
RUN apt-get install -y libffi-dev libssl-dev
RUN pip install pyopenssl ndg-httpsclient pyasn1
并运行相同的python命令,我不再收到警告.
如果您在安装pyopenssl时确实不想要警告,可以设置环境变量:PYTHONWARNINGS =“ignore:一个真正的SSLContext对象”,如下所示:https://github.com/pypa/pip/pull/3109
你的Dockerfile看起来像这样:
FROM ubuntu:14.04
# Install packages
RUN apt-get update && apt-get 香港vps install -y \
git \
libMysqLclient-dev \
MysqL-server \
Nginx \
python-dev \
python-MysqLdb \
python-setuptools \
supervisor \
vim
RUN easy_install pip
# Handle urllib3 InsecureplatformWarning
RUN apt-get install -y libffi-dev libssl-dev
ENV PYTHONWARNINGS="ignore:a true SSLContext object"
RUN pip install pyopenssl ndg-httpsclient pyasn1
另一个解决方案是将python升级到2.7.9
本站总结
以上是本站教程为你收集整理的python – 构建Docker镜像时的InsecurePlatformWarning全部内容,希望文章能够帮你解决python – 构建Docker镜像时的InsecurePlatformWarning所遇到的程序开发问题。
如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。