mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Stop trying to load images on an incompatible OS
Signed-off-by: John Stephens <johnstep@docker.com>
This commit is contained in:
parent
33fd3817b0
commit
b9255e4a53
1 changed files with 28 additions and 1 deletions
|
@ -79,6 +79,9 @@ func (l *tarexporter) Load(inTar io.ReadCloser, outStream io.Writer, quiet bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := checkCompatibleOS(img.OS); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
var rootFS image.RootFS
|
var rootFS image.RootFS
|
||||||
rootFS = *img.RootFS
|
rootFS = *img.RootFS
|
||||||
rootFS.DiffIDs = nil
|
rootFS.DiffIDs = nil
|
||||||
|
@ -292,11 +295,18 @@ func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[str
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var img struct{ Parent string }
|
var img struct {
|
||||||
|
OS string
|
||||||
|
Parent string
|
||||||
|
}
|
||||||
if err := json.Unmarshal(imageJSON, &img); err != nil {
|
if err := json.Unmarshal(imageJSON, &img); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := checkCompatibleOS(img.OS); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var parentID image.ID
|
var parentID image.ID
|
||||||
if img.Parent != "" {
|
if img.Parent != "" {
|
||||||
for {
|
for {
|
||||||
|
@ -402,3 +412,20 @@ func checkValidParent(img, parent *image.Image) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkCompatibleOS(os string) error {
|
||||||
|
// TODO @jhowardmsft LCOW - revisit for simultaneous platforms
|
||||||
|
platform := runtime.GOOS
|
||||||
|
if system.LCOWSupported() {
|
||||||
|
platform = "linux"
|
||||||
|
}
|
||||||
|
// always compatible if the OS matches; also match an empty OS
|
||||||
|
if os == platform || os == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// for compatibility, only fail if the image or runtime OS is Windows
|
||||||
|
if os == "windows" || platform == "windows" {
|
||||||
|
return fmt.Errorf("cannot load %s image on %s", os, platform)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue