1
0
mirror of https://github.com/rancher/os.git synced 2025-09-03 15:54:24 +00:00

Support higher verion docker-ce as system-docker

This commit is contained in:
niusmallnan
2018-02-27 17:55:59 +08:00
committed by niusmallnan
parent a7ba5d045b
commit 43f483a5ef
5 changed files with 17 additions and 12 deletions

View File

@@ -2,11 +2,13 @@ package init
import (
"os"
"os/exec"
"path"
"syscall"
"golang.org/x/net/context"
"github.com/docker/engine-api/types"
"github.com/docker/libcompose/project/options"
"github.com/rancher/os/cmd/control"
"github.com/rancher/os/compose"
@@ -74,22 +76,22 @@ func loadImages(cfg *config.CloudConfig) (*config.CloudConfig, error) {
continue
}
// client.ImageLoad is an asynchronous operation
// To ensure the order of execution, use cmd instead of it
inputFileName := path.Join(config.ImagesPath, image)
input, err := os.Open(inputFileName)
if err != nil {
return cfg, err
}
defer input.Close()
log.Infof("Loading images from %s", inputFileName)
if _, err = client.ImageLoad(context.Background(), input, true); err != nil {
if err = exec.Command("/usr/bin/system-docker", "load", "-q", "-i", inputFileName).Run(); err != nil {
log.Fatalf("FATAL: failed loading images from %s: %s", inputFileName, err)
}
log.Infof("Done loading images from %s", inputFileName)
}
dockerImages, _ := client.ImageList(context.Background(), types.ImageListOptions{})
for _, dimg := range dockerImages {
log.Infof("Got image repo tags: %s", dimg.RepoTags)
}
return cfg, nil
}