大网数据广告活动
服务器运维问答

Docker Compose selective attaching to services

· 52CE 我爱测

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-…

问题原文

原帖链接 · Andrei Dascalu · CC BY-SA 3.0

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!

已采纳解答

原帖链接 · todinov · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-01-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。