InsecurePlatformWarning建设码头工人形象

问题描述:

当我建立我的码头工人形象时,得到这样的警告:InsecurePlatformWarning建设码头工人形象

/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 information, 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 
+0

尝试使用--upgrade标志,例如:'RUN pip install --upgrade pyopenssl ndg-httpsclient pyasn1' – dopstar

+0

没有运气(这是有道理的,因为没有存在ng包,以便在Docker映像生成时升级 - 除非我误解'pip install --upgrade')。 –

+0

尝试在'RUN apt-get install -y libffi-dev libssl-dev'中添加'libpython2.7-dev'。 'pip安装请求[安全性]'而不是'pip install pyopenssl'更好' – ahmed

似乎运行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 

,然后运行该容器内:

[email protected]:/# 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 information. 

>>> 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 information, 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:a true SSLContext object"的建议在这里:https://github.com/pypa/pip/pull/3109

然后你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 
ENV PYTHONWARNINGS="ignore:a true SSLContext object" 
RUN pip install pyopenssl ndg-httpsclient pyasn1 

另一个解决方法是将Python升级到2.7.9