@@ -48,21 +48,17 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis
48
48
fmt .Printf ("Attaching to %s\n " , strings .Join (names , ", " ))
49
49
50
50
for _ , container := range containers {
51
- err := s .attachContainer (ctx , container , listener , project )
51
+ err := s .attachContainer (ctx , container , listener )
52
52
if err != nil {
53
53
return nil , err
54
54
}
55
55
}
56
56
return containers , err
57
57
}
58
58
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 {
60
60
serviceName := container .Labels [api .ServiceLabel ]
61
61
containerName := getContainerNameWithoutProject (container )
62
- service , err := project .GetService (serviceName )
63
- if err != nil {
64
- return err
65
- }
66
62
67
63
listener (api.ContainerEvent {
68
64
Type : api .ContainerEventAttach ,
@@ -78,7 +74,13 @@ func (s *composeService) attachContainer(ctx context.Context, container moby.Con
78
74
Line : line ,
79
75
})
80
76
})
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 )
82
84
return err
83
85
}
84
86
0 commit comments