title: How to get command docker shell prompt from python call
body: <p>I am now creating tools to assist workflow in CI/CD. One feature that I need to make is equivalent to <code>docker run ... /bin/bash</code>. It means container will be prompt for me to input command to it.</p>
  <p>Since my CI/CD is written in Python. I pick <a href="https://docker-py.readthedocs.io/en/stable/containers.html" rel="nofollow noreferrer">docker package</a></p>
  <p>I have tried</p>
  <pre><code>In [4]: client.containers.run('alpine', &quot;/bin/sh&quot;)
  Out[4]: b''
  In [5]: client.containers.run('alpine', &quot;/bin/sh&quot;, detach=False)
  Out[5]: b''
  In [6]: client.containers.run('alpine', &quot;/bin/sh&quot;, detach=False, stdin_open=True)
  stdin_open will hang in there nothing more
  </code></pre>
  <p><strong>Question:</strong><br>
  How to get a container shell prompt by calling from Python?</p>
  <p><strong>References</strong>:</p>
  <p><a href="https://docker-py.readthedocs.io/en/stable/containers.html" rel="nofollow noreferrer">https://docker-py.readthedocs.io/en/stable/containers.html</a></p>