Fix issue where `compose logs` doesn't exit when all running containers have been stopped
@@ -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]
@@ -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)