1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/export.go
Doug Davis 0a734182eb Move more 'daemon' errors to the new error package
Signed-off-by: Doug Davis <dug@us.ibm.com>
2015-09-23 09:51:45 -07:00

28 lines
684 B
Go

package daemon
import (
"io"
derr "github.com/docker/docker/errors"
)
// ContainerExport writes the contents of the container to the given
// writer. An error is returned if the container cannot be found.
func (daemon *Daemon) ContainerExport(name string, out io.Writer) error {
container, err := daemon.Get(name)
if err != nil {
return err
}
data, err := container.export()
if err != nil {
return derr.ErrorCodeExportFailed.WithArgs(name, err)
}
defer data.Close()
// Stream the entire contents of the container (basically a volatile snapshot)
if _, err := io.Copy(out, data); err != nil {
return derr.ErrorCodeExportFailed.WithArgs(name, err)
}
return nil
}