MCPcopy Index your code
hub / github.com/containerd/containerd / Exec

Method Exec

internal/cri/server/streaming.go:42–62  ·  view source on GitHub ↗

Exec executes a command inside the container. executil.ExitError is returned if the command returns non-zero exit code.

(ctx context.Context, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser,
	tty bool, resize <-chan remotecommand.TerminalSize)

Source from the content-addressed store, hash-verified

40// Exec executes a command inside the container. executil.ExitError is returned if the command
41// returns non-zero exit code.
42func (s *streamRuntime) Exec(ctx context.Context, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser,
43 tty bool, resize <-chan remotecommand.TerminalSize) error {
44 exitCode, err := s.c.execInContainer(ctrdutil.WithNamespace(ctx), containerID, execOptions{
45 cmd: cmd,
46 stdin: stdin,
47 stdout: stdout,
48 stderr: stderr,
49 tty: tty,
50 resize: resize,
51 })
52 if err != nil {
53 return fmt.Errorf("failed to exec in container: %w", err)
54 }
55 if *exitCode == 0 {
56 return nil
57 }
58 return &executil.CodeExitError{
59 Err: fmt.Errorf("error executing command %v, exit code %d", cmd, *exitCode),
60 Code: int(*exitCode),
61 }
62}
63
64func (s *streamRuntime) Attach(ctx context.Context, containerID string, in io.Reader, out, err io.WriteCloser, tty bool,
65 resize <-chan remotecommand.TerminalSize) error {

Callers

nothing calls this directly

Calls 1

execInContainerMethod · 0.80

Tested by

no test coverage detected