NOTE: I have seen other posts on this, but not a single post can explain the answer, nor do they have one that works.
Is there a way to get the output of exec_command, specifically for exec_command('docker run <CONTAINER_ID>') in real-time for the Paramiko package?
You may read lines from ChannelFile (http://docs.paramiko.org/en/2.4/api/channel.html?highlight=stdout#paramiko.channel.ChannelFile).
Example:
stdin, stdout, stderr = client.exec_command('docker run <CONTAINER_ID>')
while True:
line = stdout.readline()
if not line:
break
print(line, end="")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With