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

Method getContainerStreams

pkg/compose/attach.go:139–162  ·  view source on GitHub ↗
(ctx context.Context, container string)

Source from the content-addressed store, hash-verified

137}
138
139func (s *composeService) getContainerStreams(ctx context.Context, container string) (io.ReadCloser, error) {
140 cnx, err := s.apiClient().ContainerAttach(ctx, container, client.ContainerAttachOptions{
141 Stream: true,
142 Stdin: false,
143 Stdout: true,
144 Stderr: true,
145 Logs: false,
146 })
147 if err == nil {
148 stdout := ContainerStdout{HijackedResponse: cnx.HijackedResponse}
149 return stdout, nil
150 }
151
152 // Fallback to logs API
153 logs, err := s.apiClient().ContainerLogs(ctx, container, client.ContainerLogsOptions{
154 ShowStdout: true,
155 ShowStderr: true,
156 Follow: true,
157 })
158 if err != nil {
159 return nil, err
160 }
161 return logs, nil
162}

Callers 1

Calls 3

apiClientMethod · 0.95
ContainerAttachMethod · 0.45
ContainerLogsMethod · 0.45

Tested by

no test coverage detected