2015-09-26 26 views
7

tôi nhận được cảnh báo này khi xây dựng hình ảnh Docker tôi:InsecurePlatformWarning khi xây dựng hình ảnh 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 information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. 

Một số nguồn (như InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately) nói rằng pip install pyopenssl ndg-httpsclient pyasn1 sẽ khắc phục vấn đề này. Nhưng tôi nhận được cảnh báo ngay sau khi pip attemps để cài đặt pyopenssl.

Dưới đây là Dockerfile tôi:

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

thử sử dụng cờ --upgrade như: 'RUN pip install --upgrade pyopenssl ndg-httpsclient pyasn1' – dopstar

+0

Không may mắn (điều này có ý nghĩa, vì không có existi ng gói cho pip để nâng cấp khi hình ảnh Docker được xây dựng - trừ khi tôi hiểu lầm 'pip install --upgrade'). –

+0

thử thêm 'libpython2.7-dev' vào trong' RUN apt-get install -y libffi-dev libssl-dev'. cũng tốt hơn là 'pip install requests [security]' thay vì 'pip install pyopenssl' – ahmed

Trả lời

2

Có vẻ như rằng cảnh báo này được mong đợi khi chạy pip: http://github.com/pypa/pip/issues/2681 nhưng khi bạn đang cài đặt pyopenssl ndg-httpsclient pyasn1, bạn sẽ không nhận được cảnh báo khi sử dụng các yêu cầu python.

Ví dụ, nếu tôi xây dựng Dockerfile này:

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 

và sau đó chạy này bên trong container:

[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 

Như bạn thấy, tôi nhận được cảnh báo. Nhưng nếu tôi thêm những dòng này trong Dockerfile:

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

và chạy các lệnh tương tự python, tôi không nhận được cảnh báo nữa.

Nếu bạn thực sự không muốn cảnh báo khi cài đặt pyopenssl, bạn có thể thiết lập các biến môi trường: PYTHONWARNINGS="ignore:a true SSLContext object" như đề xuất ở đây: https://github.com/pypa/pip/pull/3109

Dockerfile của bạn sau đó sẽ trông như thế này:

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 

Một giải pháp sẽ là nâng cấp python lên 2.7.9

Các vấn đề liên quan