Skip to content

Commit a2899d5

Browse files
authored
Merge pull request docker#10181 from laurazard/fix-log-f
Fix issue where `compose logs` doesn't exit when all running containers have been stopped
2 parents 6c795d6 + 220626e commit a2899d5

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)