image_save.go 482 B

1234567891011121314151617181920212223
  1. package client
  2. import (
  3. "io"
  4. "net/url"
  5. "golang.org/x/net/context"
  6. )
  7. // ImageSave retrieves one or more images from the docker host as a io.ReadCloser.
  8. // It's up to the caller to store the images and close the stream.
  9. func (cli *Client) ImageSave(ctx context.Context, imageIDs []string) (io.ReadCloser, error) {
  10. query := url.Values{
  11. "names": imageIDs,
  12. }
  13. resp, err := cli.get(ctx, "/images/get", query, nil)
  14. if err != nil {
  15. return nil, err
  16. }
  17. return resp.body, nil
  18. }