From a1f7be7b5c61660daca10f4dc3e385a77d258e22 Mon Sep 17 00:00:00 2001 From: Stephen Thirlwall Date: Sat, 30 Oct 2021 17:29:25 +1100 Subject: [PATCH] Don't exit on container destroy events Fixes #8747 When the event is a container destroy, calling ContainerInspect returns an error, because the container no longer exists. This causes both `docker-compose up` and `docker-compose logs -f` to exit when removing a stopped container. This container has already emitted its die event, and has already been cleaned up. I believe all that needs doing in this case is to early-out. Signed-off-by: Stephen Thirlwall --- pkg/compose/start.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/compose/start.go b/pkg/compose/start.go index f06fd2280..1b12614ca 100644 --- a/pkg/compose/start.go +++ b/pkg/compose/start.go @@ -94,6 +94,12 @@ func (s *composeService) watchContainers(ctx context.Context, projectName string err := s.Events(ctx, projectName, api.EventsOptions{ Services: services, Consumer: func(event api.Event) error { + if (event.Status == "destroy") { + // This container can't be inspected, because it's gone. + // Its already been removed from the watched map. + return nil + } + inspected, err := s.apiClient.ContainerInspect(ctx, event.Container) if err != nil { return err