1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix docker pull on windows

Exceptions for the windows base layer handling.
    
    
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2015-11-12 09:33:43 -08:00
parent ce29a8cc37
commit 18c7c34d4b
4 changed files with 32 additions and 2 deletions

View file

@ -720,7 +720,9 @@ func (graph *Graph) storeImage(id, parent string, config []byte, layerData io.Re
return err
}
if img.ParentID.Validate() == nil && parent != img.ParentID.Hex() {
if (img.ParentID.Validate() == nil && parent != img.ParentID.Hex()) || (allowBaseParentImage && img.ParentID == "" && parent != "") {
// save compatibilityID parent if it doesn't match parentID
// on windows always save a parent file pointing to the base layer
if err := ioutil.WriteFile(filepath.Join(root, parentFileName), []byte(parent), 0600); err != nil {
return err
}

8
graph/graph_unix.go Normal file
View file

@ -0,0 +1,8 @@
// +build !windows
package graph
// allowBaseParentImage allows images to define a custom parent that is not
// transported with push/pull but already included with the installation.
// Only used in Windows.
const allowBaseParentImage = false

8
graph/graph_windows.go Normal file
View file

@ -0,0 +1,8 @@
// +build windows
package graph
// allowBaseParentImage allows images to define a custom parent that is not
// transported with push/pull but already included with the installation.
// Only used in Windows.
const allowBaseParentImage = true

View file

@ -500,7 +500,8 @@ func fixManifestLayers(m *schema1.Manifest) error {
}
}
if images[len(images)-1].Parent != "" {
if images[len(images)-1].Parent != "" && !allowBaseParentImage {
// Windows base layer can point to a base layer parent that is not in manifest.
return errors.New("Invalid parent ID in the base layer of the image.")
}
@ -548,6 +549,17 @@ func (p *v2Puller) getImageInfos(m *schema1.Manifest) ([]contentAddressableDescr
p.attemptIDReuse(imgs)
// reset the base layer parent for windows
if allowBaseParentImage {
var base struct{ Parent string }
if err := json.Unmarshal(imgs[len(imgs)-1].v1Compatibility, &base); err != nil {
return nil, err
}
if base.Parent != "" {
imgs[len(imgs)-1].parent = base.Parent
}
}
return imgs, nil
}