github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/client/lib/image_create.go (about) 1 package lib 2 3 import ( 4 "io" 5 "net/url" 6 7 "github.com/docker/docker/api/types" 8 ) 9 10 // ImageCreate creates a new image based in the parent options. 11 // It returns the JSON content in the response body. 12 func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) { 13 query := url.Values{} 14 query.Set("fromImage", options.Parent) 15 query.Set("tag", options.Tag) 16 resp, err := cli.tryImageCreate(query, options.RegistryAuth) 17 if err != nil { 18 return nil, err 19 } 20 return resp.body, nil 21 } 22 23 func (cli *Client) tryImageCreate(query url.Values, registryAuth string) (*serverResponse, error) { 24 headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 25 return cli.post("/images/create", query, nil, headers) 26 }