Skip to content

Commit

Permalink
Optionally use podman load instead of docker load
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Jan 25, 2019
1 parent 00be38d commit 25ad2d3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ func CacheImages(images []string, cacheDir string) error {

func LoadImages(cmd bootstrapper.CommandRunner, images []string, cacheDir string) error {
var g errgroup.Group
// Load profile cluster config from file
cc, err := config.Load()
if err != nil && !os.IsNotExist(err) {
glog.Errorln("Error loading profile config: ", err)
}
for _, image := range images {
image := image
g.Go(func() error {
src := filepath.Join(cacheDir, image)
src = sanitizeCacheDir(src)
if err := LoadFromCacheBlocking(cmd, src); err != nil {
if err := LoadFromCacheBlocking(cmd, cc.KubernetesConfig, src); err != nil {
return errors.Wrapf(err, "loading image %s", src)
}
return nil
Expand Down Expand Up @@ -190,7 +195,7 @@ func getWindowsVolumeNameCmd(d string) (string, error) {
return vname, nil
}

func LoadFromCacheBlocking(cmd bootstrapper.CommandRunner, src string) error {
func LoadFromCacheBlocking(cmd bootstrapper.CommandRunner, k8s config.KubernetesConfig, src string) error {
glog.Infoln("Loading image from cache at ", src)
filename := filepath.Base(src)
for {
Expand All @@ -207,7 +212,12 @@ func LoadFromCacheBlocking(cmd bootstrapper.CommandRunner, src string) error {
return errors.Wrap(err, "transferring cached image")
}

dockerLoadCmd := "docker load -i " + dst
var dockerLoadCmd string
if k8s.ContainerRuntime == constants.CrioRuntime || k8s.ContainerRuntime == constants.Cri_oRuntime {
dockerLoadCmd = "sudo podman load -i " + dst
} else {
dockerLoadCmd = "docker load -i " + dst
}

if err := cmd.Run(dockerLoadCmd); err != nil {
return errors.Wrapf(err, "loading docker image: %s", dst)
Expand Down

0 comments on commit 25ad2d3

Please sign in to comment.