Merge pull request #10181 from laurazard/fix-log-f

Fix issue where `compose logs` doesn't exit when all running containers have been stopped
This commit is contained in:
Guillaume Lours 2023-01-20 14:11:31 +01:00 committed by GitHub
commit a2899d5ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -99,6 +99,12 @@ func isService(services ...string) containerPredicate {
}
}
func isRunning() containerPredicate {
return func(c moby.Container) bool {
return c.State == "running"
}
}
func isNotService(services ...string) containerPredicate {
return func(c moby.Container) bool {
service := c.Labels[api.ServiceLabel]

View File

@ -72,6 +72,7 @@ func (s *composeService) Logs(
}
if options.Follow {
containers = containers.filter(isRunning())
printer := newLogPrinter(consumer)
eg.Go(func() error {
_, err := printer.Run(false, "", nil)