python - InsecurePlatformWarning when building Docker image -


i warning when building docker image:

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:79:        insecureplatformwarning: true sslcontext object not available.        prevents urllib3 configuring ssl appropriately , may cause ssl connections fail.        more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. 

several sources (like insecureplatformwarning: true sslcontext object not available. prevents urllib3 configuring ssl appropriately) pip install pyopenssl ndg-httpsclient pyasn1 fix issue. warning pip attemps install pyopenssl.

here's 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 

it seems warning expected when running pip: http://github.com/pypa/pip/issues/2681 installing pyopenssl ndg-httpsclient pyasn1, won't warnings when using python requests.

for example, if build 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 

and run inside container:

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" 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: true sslcontext object not available. prevents urllib3 configuring ssl appropriately , may cause ssl connections fail. more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.    insecureplatformwarning 

as can see, warning. if add these lines in dockerfile:

run apt-get install -y libffi-dev libssl-dev run pip install pyopenssl ndg-httpsclient pyasn1 

and run same python commands, don't warning anymore.

if don't want warning when installing pyopenssl, can set environment variable: pythonwarnings="ignore:a true sslcontext object" suggested here: https://github.com/pypa/pip/pull/3109

your dockerfile this:

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 

another solution upgrade python 2.7.9


Comments