container_export.go 509 B

12345678910111213141516171819
  1. package client // import "github.com/docker/docker/client"
  2. import (
  3. "context"
  4. "io"
  5. "net/url"
  6. )
  7. // ContainerExport retrieves the raw contents of a container
  8. // and returns them as an 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. }