container_export.go 482 B

123456789101112131415161718192021
  1. package client
  2. import (
  3. "io"
  4. "net/url"
  5. "golang.org/x/net/context"
  6. )
  7. // ContainerExport retrieves the raw contents of a container
  8. // and returns them as a io.ReadCloser. It's up to the caller
  9. // to close the stream.
  10. func (cli *Client) ContainerExport(ctx context.Context, containerID string) (io.ReadCloser, error) {
  11. serverResp, err := cli.get(ctx, "/containers/"+containerID+"/export", url.Values{}, nil)
  12. if err != nil {
  13. return nil, err
  14. }
  15. return serverResp.body, nil
  16. }