I docker that output logs stdout stderr, which can be viewed using:
docker logs -f $LOGS_CONTAINER_ID
I also added 'sed', which puts the container id on each line:
docker logs -f $LOGS_CONTAINER_ID | sed "s/^/$LOGS_CONTAINER_ID /"
If I run it, I get something like:
container112 error 10:20:10 problem container112 info 10:20:09 not problem container112 error 10:20:01 problem
where "container112" is $LOGS_CONTAINER_ID.
SO FAR SO GOOD. Now I want to output the above command to a file (log.out), so I wrote the following command:
docker logs -f $LOGS_CONTAINER_ID | sed "s/^/$LOGS_CONTAINER_ID /" >> log.out
What happens is that it writes the logs to log.out, but it doesn't get new logs (if I open a new session and run
tail -f log.out, I don't get output).
So I also tried:
tail -f $(docker logs -f $LOGS_CONTAINER_ID | sed "s/^/$LOGS_CONTAINER_ID /") >> log.out
But it also didn't work. What is the problem?