Skip to content

Commit

Permalink
inspect container before attachment to use the adequate logic regardi…
Browse files Browse the repository at this point in the history
…ng TTY

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Apr 4, 2022
1 parent f2d9acd commit 6967dc3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/compose/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}

Expand Down

0 comments on commit 6967dc3

Please sign in to comment.