MCPcopy Index your code
hub / github.com/docker/cli / interactiveExec

Function interactiveExec

cli/command/container/exec.go:139–202  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, execOptions *client.ExecCreateOptions, execID string)

Source from the content-addressed store, hash-verified

137}
138
139func interactiveExec(ctx context.Context, dockerCli command.Cli, execOptions *client.ExecCreateOptions, execID string) error {
140 // Interactive exec requested.
141 var (
142 out, stderr io.Writer
143 in io.ReadCloser
144 )
145
146 if execOptions.AttachStdin {
147 in = dockerCli.In()
148 }
149 if execOptions.AttachStdout {
150 out = dockerCli.Out()
151 }
152 if execOptions.AttachStderr {
153 if execOptions.TTY {
154 stderr = dockerCli.Out()
155 } else {
156 stderr = dockerCli.Err()
157 }
158 }
159 fillConsoleSize(execOptions, dockerCli)
160
161 apiClient := dockerCli.Client()
162 resp, err := apiClient.ExecAttach(ctx, execID, client.ExecAttachOptions{
163 TTY: execOptions.TTY,
164 ConsoleSize: client.ConsoleSize{Height: execOptions.ConsoleSize.Height, Width: execOptions.ConsoleSize.Width},
165 })
166 if err != nil {
167 return err
168 }
169 defer resp.Close()
170
171 errCh := make(chan error, 1)
172
173 go func() {
174 defer close(errCh)
175 errCh <- func() error {
176 streamer := hijackedIOStreamer{
177 streams: dockerCli,
178 inputStream: in,
179 outputStream: out,
180 errorStream: stderr,
181 resp: resp.HijackedResponse,
182 tty: execOptions.TTY,
183 detachKeys: execOptions.DetachKeys,
184 }
185
186 return streamer.stream(ctx)
187 }()
188 }()
189
190 if execOptions.TTY && dockerCli.In().IsTerminal() {
191 if err := MonitorTtySize(ctx, dockerCli, execID, true); err != nil {
192 _, _ = fmt.Fprintln(dockerCli.Err(), "Error monitoring TTY size:", err)
193 }
194 }
195
196 if err := <-errCh; err != nil {

Callers 1

RunExecFunction · 0.85

Calls 10

streamMethod · 0.95
fillConsoleSizeFunction · 0.85
MonitorTtySizeFunction · 0.85
getExecExitStatusFunction · 0.85
InMethod · 0.65
OutMethod · 0.65
ErrMethod · 0.65
ClientMethod · 0.65
CloseMethod · 0.45
IsTerminalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…