mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Ensure that only the layers are compressed and not mnt points
This commit is contained in:
parent
8fdbf46afb
commit
4e0c76b321
2 changed files with 21 additions and 4 deletions
2
graph.go
2
graph.go
|
@ -187,7 +187,7 @@ func (graph *Graph) TempLayerArchive(id string, compression archive.Compression,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a, err := image.TarLayer(compression)
|
||||
a, err := image.TarLayer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
23
image.go
23
image.go
|
@ -144,15 +144,32 @@ func jsonPath(root string) string {
|
|||
}
|
||||
|
||||
// TarLayer returns a tar archive of the image's filesystem layer.
|
||||
func (img *Image) TarLayer(compression archive.Compression) (archive.Archive, error) {
|
||||
func (img *Image) TarLayer() (archive.Archive, error) {
|
||||
if img.graph == nil {
|
||||
return nil, fmt.Errorf("Can't load storage driver for unregistered image %s", img.ID)
|
||||
}
|
||||
layerPath, err := img.graph.driver.Get(img.ID)
|
||||
driver := img.graph.driver
|
||||
if differ, ok := driver.(graphdriver.Differ); ok {
|
||||
return differ.Diff(img.ID)
|
||||
}
|
||||
|
||||
imgFs, err := driver.Get(img.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return archive.Tar(layerPath, compression)
|
||||
if img.Parent == "" {
|
||||
return archive.Tar(imgFs, archive.Uncompressed)
|
||||
} else {
|
||||
parentFs, err := driver.Get(img.Parent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
changes, err := archive.ChangesDirs(imgFs, parentFs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return archive.ExportChanges(imgFs, changes)
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateID(id string) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue