MCPcopy
hub / github.com/docker/compose / doAttachContainer

Method doAttachContainer

pkg/compose/attach.go:72–103  ·  pkg/compose/attach.go::composeService.doAttachContainer
(ctx context.Context, service, id, name string, listener api.ContainerEventListener)

Source from the content-addressed store, hash-verified

70}
71
72func (s *composeService) doAttachContainer(ctx context.Context, service, id, name string, listener api.ContainerEventListener) error {
73 inspect, err := s.apiClient().ContainerInspect(ctx, id, client.ContainerInspectOptions{})
74 if err != nil {
75 return err
76 }
77
78 wOut := utils.GetWriter(func(line string) {
79 listener(api.ContainerEvent{
80 Type: api.ContainerEventLog,
81 Source: name,
82 ID: id,
83 Service: service,
84 Line: line,
85 })
86 })
87 wErr := utils.GetWriter(func(line string) {
88 listener(api.ContainerEvent{
89 Type: api.ContainerEventErr,
90 Source: name,
91 ID: id,
92 Service: service,
93 Line: line,
94 })
95 })
96
97 err = s.attachContainerStreams(ctx, id, inspect.Container.Config.Tty, wOut, wErr)
98 if err != nil {
99 return err
100 }
101
102 return nil
103}
104
105func (s *composeService) attachContainerStreams(ctx context.Context, container string, tty bool, stdout, stderr io.WriteCloser) error {
106 streamOut, err := s.getContainerStreams(ctx, container)

Callers 2

attachContainerMethod · 0.95
UpMethod · 0.95

Calls 4

apiClientMethod · 0.95
GetWriterFunction · 0.92
ContainerInspectMethod · 0.45

Tested by

no test coverage detected