1package client // import "github.com/docker/docker/client" 2 3import ( 4 "context" 5 "encoding/json" 6 "net/url" 7 8 "github.com/docker/docker/api/types" 9) 10 11// ImageRemove removes an image from the docker host. 12func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) { 13 query := url.Values{} 14 15 if options.Force { 16 query.Set("force", "1") 17 } 18 if !options.PruneChildren { 19 query.Set("noprune", "1") 20 } 21 22 var dels []types.ImageDeleteResponseItem 23 resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) 24 defer ensureReaderClosed(resp) 25 if err != nil { 26 return dels, wrapResponseError(err, resp, "image", imageID) 27 } 28 29 err = json.NewDecoder(resp.body).Decode(&dels) 30 return dels, err 31} 32