github.com/feiyang21687/docker@v1.5.0/daemon/export.go (about) 1 package daemon 2 3 import ( 4 "io" 5 6 "github.com/docker/docker/engine" 7 ) 8 9 func (daemon *Daemon) ContainerExport(job *engine.Job) engine.Status { 10 if len(job.Args) != 1 { 11 return job.Errorf("Usage: %s container_id", job.Name) 12 } 13 name := job.Args[0] 14 if container := daemon.Get(name); container != nil { 15 data, err := container.Export() 16 if err != nil { 17 return job.Errorf("%s: %s", name, err) 18 } 19 defer data.Close() 20 21 // Stream the entire contents of the container (basically a volatile snapshot) 22 if _, err := io.Copy(job.Stdout, data); err != nil { 23 return job.Errorf("%s: %s", name, err) 24 } 25 // FIXME: factor job-specific LogEvent to engine.Job.Run() 26 container.LogEvent("export") 27 return engine.StatusOK 28 } 29 return job.Errorf("No such container: %s", name) 30 }