Docker Compose selective attaching to services

dockerdocker-compose

It's possible that I may be blind or stupid but I have a fairly simple problem for which, aside form not being able to accurately describe it in the title, I wasn't able to find a straightforward solution online.

I have a docker-compose.yml describing about 10 services that generally need each other.

On docker-compose up I'm left attached to running containers, which I generally need, to follow logged stuff in real time.

However, for only 2 of those containers, I do not want this to happen (they are stuff like rabbitmq and elasticsearch and I'm not interested in what they have to say unless they fail altogether).

Is it possible to run docker-compose up and somehow exclude those 2? Rather than preventing them from logging stuff, I'm wondering if there's a way to just not attach to them. I know I can just detach and manually attach to the 8 left, but that's not very convenient.

Thanks!

Best Answer

Run ther containers without attaching:

docker-compose up -d

And then use the logs subcommand to only get the relevant logs:

docker-compose logs -f service1 service2 service3

-f will live tail the logs.