@@ -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
0 commit comments