image_create.go 733 B

1234567891011121314151617181920212223242526
  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. query := url.Values{}
  11. query.Set("fromImage", options.Parent)
  12. query.Set("tag", options.Tag)
  13. resp, err := cli.tryImageCreate(query, options.RegistryAuth)
  14. if err != nil {
  15. return nil, err
  16. }
  17. return resp.body, nil
  18. }
  19. func (cli *Client) tryImageCreate(query url.Values, registryAuth string) (*serverResponse, error) {
  20. headers := map[string][]string{"X-Registry-Auth": {registryAuth}}
  21. return cli.post("/images/create", query, nil, headers)
  22. }