github.com/projectatomic/docker@v1.8.2/daemon/export.go (about)

     1  package daemon
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  )
     7  
     8  func (daemon *Daemon) ContainerExport(name string, out io.Writer) error {
     9  	container, err := daemon.Get(name)
    10  	if err != nil {
    11  		return err
    12  	}
    13  
    14  	data, err := container.Export()
    15  	if err != nil {
    16  		return fmt.Errorf("%s: %s", name, err)
    17  	}
    18  	defer data.Close()
    19  
    20  	// Stream the entire contents of the container (basically a volatile snapshot)
    21  	if _, err := io.Copy(out, data); err != nil {
    22  		return fmt.Errorf("%s: %s", name, err)
    23  	}
    24  	return nil
    25  }