Is there any way to see logs in follow mode after docker-compose stop?

Viewed 555

For example, I started my system: docker-compose up -d

And then I see logs in follow mode: docker-compose logs -f

But if I stop system with docker-compose stop then my docker-compose logs -f will exit. Is there any way to "wait" until system starts?

3 Answers

It looks like, as of 2019, there's no way to do this.

docker/compose#2227 suggests that it's intentional that docker-compose logs -f exits once there are no more containers running:

if the log stream is done (the containers have stopped) logs should exit

I used to do it like this:

while true ; do docker-compose -f docker-compose.dev.yml logs -f ; sleep 5 ; echo "Are you loopy?" ; done

However, due to a bug in docker(-compose), the docker-compose logs process currently does not return to prompt when a docker-compose -f docker-compose.dev.yml down is invoked in a second terminal.

Related