github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/client/image_load.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "io" 6 "net/url" 7 8 "github.com/docker/docker/api/types" 9 ) 10 11 // ImageLoad loads an image in the docker host from the client host. 12 // It's up to the caller to close the io.ReadCloser in the 13 // ImageLoadResponse returned by this function. 14 func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) { 15 v := url.Values{} 16 v.Set("quiet", "0") 17 if quiet { 18 v.Set("quiet", "1") 19 } 20 headers := map[string][]string{"Content-Type": {"application/x-tar"}} 21 resp, err := cli.postRaw(ctx, "/images/load", v, input, headers) 22 if err != nil { 23 return types.ImageLoadResponse{}, err 24 } 25 return types.ImageLoadResponse{ 26 Body: resp.body, 27 JSON: resp.header.Get("Content-Type") == "application/json", 28 }, nil 29 }