ac2a028dcc
To prevent a circular import between api/types and api/types image, the RequestPrivilegeFunc reference was not moved, but defined as part of the PullOptions / PushOptions. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
31 lines
710 B
Go
31 lines
710 B
Go
package client // import "github.com/docker/docker/client"
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/docker/docker/api/types/image"
|
|
)
|
|
|
|
// ImageRemove removes an image from the docker host.
|
|
func (cli *Client) ImageRemove(ctx context.Context, imageID string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
|
query := url.Values{}
|
|
|
|
if options.Force {
|
|
query.Set("force", "1")
|
|
}
|
|
if !options.PruneChildren {
|
|
query.Set("noprune", "1")
|
|
}
|
|
|
|
var dels []image.DeleteResponse
|
|
resp, err := cli.delete(ctx, "/images/"+imageID, query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return dels, err
|
|
}
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&dels)
|
|
return dels, err
|
|
}
|