container = client.create_container(image='busybox:latest', stdin_open=True,
    tty=True, command='/bin/sh')
client.start(container)
dockerpty.PseudoTerminal(client, container).start()
How to use docker-py (official docker client) to start a bash shell?