image_create.go 582 B

1234567891011121314151617181920212223
  1. package lib
  2. import (
  3. "io"
  4. "net/url"
  5. "github.com/docker/docker/api/types"
  6. )
  7. // ImageCreate creates a new image based in the parent options.
  8. // It returns the JSON content in the response body.
  9. func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) {
  10. var query url.Values
  11. query.Set("fromImage", options.Parent)
  12. query.Set("tag", options.Tag)
  13. headers := map[string][]string{"X-Registry-Auth": {options.RegistryAuth}}
  14. resp, err := cli.POST("/images/create", query, nil, headers)
  15. if err != nil {
  16. return nil, err
  17. }
  18. return resp.body, nil
  19. }