Skip to content

Commit c9fbb9b

Browse files
committed
inspect container before attachment to use the adequate logic regarding TTY
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent f2d9acd commit c9fbb9b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/compose/attach.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,17 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis
4848
fmt.Printf("Attaching to %s\n", strings.Join(names, ", "))
4949

5050
for _, container := range containers {
51-
err := s.attachContainer(ctx, container, listener, project)
51+
err := s.attachContainer(ctx, container, listener)
5252
if err != nil {
5353
return nil, err
5454
}
5555
}
5656
return containers, err
5757
}
5858

59-
func (s *composeService) attachContainer(ctx context.Context, container moby.Container, listener api.ContainerEventListener, project *types.Project) error {
59+
func (s *composeService) attachContainer(ctx context.Context, container moby.Container, listener api.ContainerEventListener) error {
6060
serviceName := container.Labels[api.ServiceLabel]
6161
containerName := getContainerNameWithoutProject(container)
62-
service, err := project.GetService(serviceName)
63-
if err != nil {
64-
return err
65-
}
6662

6763
listener(api.ContainerEvent{
6864
Type: api.ContainerEventAttach,
@@ -78,7 +74,13 @@ func (s *composeService) attachContainer(ctx context.Context, container moby.Con
7874
Line: line,
7975
})
8076
})
81-
_, _, err = s.attachContainerStreams(ctx, container.ID, service.Tty, nil, w, w)
77+
78+
inspect, err := s.dockerCli.Client().ContainerInspect(ctx, container.ID)
79+
if err != nil {
80+
return err
81+
}
82+
83+
_, _, err = s.attachContainerStreams(ctx, container.ID, inspect.Config.Tty, nil, w, w)
8284
return err
8385
}
8486

pkg/compose/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
5555

5656
eg.Go(func() error {
5757
return s.watchContainers(context.Background(), project.Name, options.AttachTo, listener, attached, func(container moby.Container) error {
58-
return s.attachContainer(ctx, container, listener, project)
58+
return s.attachContainer(ctx, container, listener)
5959
})
6060
})
6161
}

0 commit comments

Comments
 (0)