Skip to content

Commit 220626e

Browse files
committed
Only account running containers for logs
Signed-off-by: Laura Brehm <[email protected]>
1 parent e94eb05 commit 220626e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/compose/containers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ func isService(services ...string) containerPredicate {
9999
}
100100
}
101101

102+
func isRunning() containerPredicate {
103+
return func(c moby.Container) bool {
104+
return c.State == "running"
105+
}
106+
}
107+
102108
func isNotService(services ...string) containerPredicate {
103109
return func(c moby.Container) bool {
104110
service := c.Labels[api.ServiceLabel]

pkg/compose/logs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (s *composeService) Logs(
7272
}
7373

7474
if options.Follow {
75+
containers = containers.filter(isRunning())
7576
printer := newLogPrinter(consumer)
7677
eg.Go(func() error {
7778
_, err := printer.Run(false, "", nil)

0 commit comments

Comments
 (0)