I am trying to get the real time stdout from a command I am running in a docker container. However, I need to do this from a remote command run from another host.

When I am on the docker host I can run my docker command with -it and get the real time output I need. However, I have this constraint where I have to run the command remotely making the previous solution useless. I cannot use -t because it runs a pseudo terminal based on $TERM which doesn't exist with the remote command because there is no terminal at all.

I have also tried running the docker command with -d to run it in the background and docker logs -f <container> but the output is still given all at once at the end of the process.

Any solutions or advice is appreciated and correct me if this belongs on another stack.

2 Answers 2


Figured this out from some help on Docker's github. I failed to mention I was trying to run a python script in the container, but I didn't think it was important.

This was actually not a docker problem, but a python issue. I learned Docker already does provide stdout in realtime. Python was holding all the stdout in its buffer and not flushing until the completion of the script. Except when the code was run in a terminal with -t.

In the docker command all I needed was to call the script with python -u <script> to prevent python from buffering the stdout.


Well why don't you use ELK stack with logsprout you can get real time logs from all docker containers plus you can search among the logs and lot of other cool stuffs

  • Logspout looks like it could be helpful, I will look more into that
    – ProdIssue
    Apr 18, 2017 at 14:24
  • If you will face any problem let me know
    – varnit
    Apr 18, 2017 at 14:24
  • Is your problem solved?
    – varnit
    Apr 18, 2017 at 17:50
  • No my problem is that for some reason my code is real time in the stdout of a terminal, but not in the stdout of a container.
    – ProdIssue
    Apr 19, 2017 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .