From 6967dc353bec6d2c2cb9f9849651729ace02c795 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 4 Apr 2022 12:15:47 +0200 Subject: [PATCH] inspect container before attachment to use the adequate logic regarding TTY Signed-off-by: Nicolas De Loof --- pkg/compose/attach.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/compose/attach.go b/pkg/compose/attach.go index b608e252e6c..eef47195d61 100644 --- a/pkg/compose/attach.go +++ b/pkg/compose/attach.go @@ -59,10 +59,6 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis func (s *composeService) attachContainer(ctx context.Context, container moby.Container, listener api.ContainerEventListener, project *types.Project) error { serviceName := container.Labels[api.ServiceLabel] containerName := getContainerNameWithoutProject(container) - service, err := project.GetService(serviceName) - if err != nil { - return err - } listener(api.ContainerEvent{ Type: api.ContainerEventAttach, @@ -78,7 +74,13 @@ func (s *composeService) attachContainer(ctx context.Context, container moby.Con Line: line, }) }) - _, _, err = s.attachContainerStreams(ctx, container.ID, service.Tty, nil, w, w) + + inspect, err := s.dockerCli.Client().ContainerInspect(ctx, container.ID) + if err != nil { + return err + } + + _, _, err = s.attachContainerStreams(ctx, container.ID, inspect.Config.Tty, nil, w, w) return err }