github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/daemon/image_exporter.go (about) 1 package daemon 2 3 import ( 4 "io" 5 "runtime" 6 7 "github.com/docker/docker/image/tarexport" 8 "github.com/docker/docker/pkg/system" 9 ) 10 11 // ExportImage exports a list of images to the given output stream. The 12 // exported images are archived into a tar when written to the output 13 // stream. All images with the given tag and all versions containing 14 // the same tag are exported. names is the set of tags to export, and 15 // outStream is the writer which the images are written to. 16 func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error { 17 // TODO @jhowardmsft LCOW. This will need revisiting later. 18 platform := runtime.GOOS 19 if system.LCOWSupported() { 20 platform = "linux" 21 } 22 imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.referenceStore, daemon) 23 return imageExporter.Save(names, outStream) 24 } 25 26 // LoadImage uploads a set of images into the repository. This is the 27 // complement of ImageExport. The input stream is an uncompressed tar 28 // ball containing images and metadata. 29 func (daemon *Daemon) LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error { 30 // TODO @jhowardmsft LCOW. This will need revisiting later. 31 platform := runtime.GOOS 32 if system.LCOWSupported() { 33 platform = "linux" 34 } 35 imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.referenceStore, daemon) 36 return imageExporter.Load(inTar, outStream, quiet) 37 }