Skip to content

Commit 541fb9c

Browse files
committed
The podman cp command is not in podman-remote
So use podman exec stdin/stdout as a workaround.
1 parent 271ca3a commit 541fb9c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

pkg/minikube/command/kic_runner.go

+23-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import (
2424
"os"
2525
"os/exec"
2626
"path"
27+
"runtime"
2728
"strconv"
29+
"strings"
2830
"time"
2931

3032
"github.com/golang/glog"
@@ -202,8 +204,27 @@ func (k *kicRunner) chmod(dst string, perm string) error {
202204

203205
// Podman cp command doesn't match docker and doesn't have -a
204206
func copyToPodman(src string, dest string) error {
205-
if out, err := oci.PrefixCmd(exec.Command(oci.Podman, "cp", src, dest)).CombinedOutput(); err != nil {
206-
return errors.Wrapf(err, "podman copy %s into %s, output: %s", src, dest, string(out))
207+
if runtime.GOOS == "linux" {
208+
cmd := oci.PrefixCmd(exec.Command(oci.Podman, "cp", src, dest))
209+
glog.Infof("Run: %v", cmd)
210+
if out, err := cmd.CombinedOutput(); err != nil {
211+
return errors.Wrapf(err, "podman copy %s into %s, output: %s", src, dest, string(out))
212+
}
213+
} else {
214+
file, err := os.Open(src)
215+
if err != nil {
216+
return err
217+
}
218+
defer file.Close()
219+
parts := strings.Split(dest, ":")
220+
container := parts[0]
221+
path := parts[1]
222+
cmd := exec.Command(oci.Podman, "exec", "-i", container, "tee", path)
223+
cmd.Stdin = file
224+
glog.Infof("Run: %v", cmd)
225+
if err := cmd.Run(); err != nil {
226+
return errors.Wrapf(err, "podman copy %s into %s", src, dest)
227+
}
207228
}
208229
return nil
209230
}

0 commit comments

Comments
 (0)