how to get a line for line output stream from .exec_run docker-py

436 views Asked by At

Looking for a solution to return the live output when executing commands inside a container using the .exec_run method.

** The scenario is for a currently running container **

Executing a command inside the container this way functions as expected.

run = container.exec_run(cmd='apt update')

We print that with .output method but this isn't a streamed 'live' output.

print(run.output.decode("utf-8"))

Would ideally like an output line for line to the console, with the ability to also dump it to a log file later, any solutions? Thanks

0

There are 0 answers