image_exporter.go 1.5 KB

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