1

I'm using docker-py and dockerpty to connect and execute commands in a container in ucp. Everything works correctly, except when I try to hijack the pseudo-terminal allocated in the container:

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)

However, when I execute the command, I am able to connect with the remote terminal, but as I type in the terminal I get:

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')]

My openssl version is:

$ openssl version
OpenSSL 1.0.2j  26 Sep 2016

while the container has:

# openssl version
OpenSSL 1.0.1t  3 May 2016

Well, both are above 1.0.1. All of I need is to disable the version verification. With the requests library I could just to do:

import requests
response = requests.get(<https url>, verify=False)

My Python version is 2.7.12 and SSL:

>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2j  26 Sep 2016

is also up to date. The container has Python 2.7.9 and SSL:

>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.1t  3 May 2016

I am about to create a fork from dockerpty and add the changes myself, unless someone has a better suggestion. What could I do to fix this issue?

jww
  • 97,681
  • 90
  • 411
  • 885
cybertextron
  • 10,547
  • 28
  • 104
  • 208

0 Answers0