1

I would like to view the output history of a Docker container. I am running the container like so:

docker run -itd --name mytest ubuntu:latest /bin/bash

I can then run the following commands:

docker exec -it mytest /bin/bash
root@f1b3fc8464d2:/# echo "it works"
it works
root@f1b3fc8464d2:/# exit

I then want to run some command to show me "it works", as well as the history of any other output, as I would have seen had I just initially stayed attached to the container the whole time. Changing the initially run command, or other kinds of enabling logging are acceptable.

Based on another stackexchange question, I've already tried this:

docker logs -f mytest

But it has no effect. It doesn't show output history, and it doesn't show output that happens while the command is running. It doesn't show anything.

5
  • github.com/moby/moby/issues/8662 – muru Jan 22 '20 at 9:47
  • What in particular are you trying to draw my attention to? – Duncan Marshall Jan 22 '20 at 9:59
  • That docker exec doesn't log anything anywhere and that issue is a FR to add logging to docker exec – muru Jan 22 '20 at 10:03
  • I'm looking to log stdout in general though, rather than just stuff as a result of docker exec. The above logs command doesn't show any output of any kind at all, even though I know there has been some. I essentially just want my pseudo terminal created with the -t flag in the run command to be perpetual outputted to a file for later perusal. – Duncan Marshall Jan 22 '20 at 10:08
  • 1
    That's the point of the issue there - if there were something general, people would be using that for docker exec instead of filing FRs – muru Jan 22 '20 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.