我使用docker-py和dockerpty在ucp
的容器中连接和执行命令。一切正常,除非我试图劫持容器中分配的伪终端:
import docker
import dockerpty
import requests
client = docker.Client()
container = client.create_container(
image='busybox:latest',
stdin_open=True,
tty=True,
command='/bin/sh',
)
requests.packages.urllib3.disable_warnings()
command = "/bin/bash"
dockerpty.exec_command(client, container, command)
然而,当我执行命令时,我能够连接远程终端,但当我输入终端时,我得到:
File "build/bdist.macosx-10.12-x86_64/egg/dockerpty/__init__.py", line 44, in exec_command
File "build/bdist.macosx-10.12-x86_64/egg/dockerpty/pty.py", line 334, in start
File "build/bdist.macosx-10.12-x86_64/egg/dockerpty/pty.py", line 373, in _hijack_tty
File "build/bdist.macosx-10.12-x86_64/egg/dockerpty/io.py", line 367, in flush
File "build/bdist.macosx-10.12-x86_64/egg/dockerpty/io.py", line 120, in read
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 194, in recv
data = self.connection.recv(*args, **kwargs)
File "build/bdist.macosx-10.11-x86_64/egg/OpenSSL/SSL.py", line 1320, in recv
File "build/bdist.macosx-10.11-x86_64/egg/OpenSSL/SSL.py", line 1187, in _raise_ssl_error
File "build/bdist.macosx-10.11-x86_64/egg/OpenSSL/_util.py", line 48, in exception_from_error_queue
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_read_bytes', 'tlsv1 alert protocol version')]
我的openssl
版本是:
$ openssl version
OpenSSL 1.0.2j 26 Sep 2016
虽然容器有:
# openssl version
OpenSSL 1.0.1t 3 May 2016
嗯,两者都高于1.0.1
。我所需要的只是禁用版本验证。使用requests
库我可以做:
import requests
response = requests.get(<https url>, verify=False)
我的Python
版本为2.7.12
和SSL
:
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2j 26 Sep 2016
也是最新的。容器有Python 2.7.9
和SSL
:
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.1t 3 May 2016
我即将从dockerpty
创建一个fork并自行添加更改,除非有人有更好的建议。我该怎么做才能解决这个问题?