MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / command

Method command

src/cmd/linuxkit/pkglib/dockerimpl.go:101–137  ·  view source on GitHub ↗
(stdin io.Reader, stdout, stderr io.Writer, args ...string)

Source from the content-addressed store, hash-verified

99}
100
101func (dr *dockerRunnerImpl) command(stdin io.Reader, stdout, stderr io.Writer, args ...string) error {
102 cmd := exec.Command("docker", args...)
103 if stdin == nil {
104 stdin = os.Stdin
105 }
106 if stdout == nil {
107 stdout = os.Stdout
108 }
109 if stderr == nil {
110 if runtime.GOOS != "windows" {
111 stderr = os.Stderr
112 } else {
113 // On Windows directly setting stderr to os.Stderr results in the output being written to stdout,
114 // corrupting the image tar. Adding an explicit indirection via a pipe works around the issue.
115 r, w := io.Pipe()
116 stderr = w
117 go func() {
118 _, _ = io.Copy(os.Stderr, r)
119 }()
120 }
121 }
122 cmd.Stdout = stdout
123 cmd.Stderr = stderr
124 cmd.Stdin = stdin
125 cmd.Env = os.Environ()
126
127 log.Debugf("Executing: %v", cmd.Args)
128
129 err := cmd.Run()
130 if err != nil {
131 if isExecErrNotFound(err) {
132 return fmt.Errorf("linuxkit pkg requires docker to be installed")
133 }
134 return err
135 }
136 return nil
137}
138
139// versionCheck returns the client version and server version, and compares them both
140// against the minimum required version.

Callers 10

versionCheckMethod · 0.95
ContextSupportCheckMethod · 0.95
BuilderMethod · 0.95
PullMethod · 0.95
pushMethod · 0.95
TagMethod · 0.95
SaveMethod · 0.95
LoadMethod · 0.95
copyFilesToContainerMethod · 0.95

Calls 1

isExecErrNotFoundFunction · 0.85

Tested by

no test coverage detected