github.com/rish1988/moby@v25.0.2+incompatible/client/volume_remove.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "net/url" 6 7 "github.com/docker/docker/api/types/versions" 8 ) 9 10 // VolumeRemove removes a volume from the docker host. 11 func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error { 12 query := url.Values{} 13 if force { 14 // Make sure we negotiated (if the client is configured to do so), 15 // as code below contains API-version specific handling of options. 16 // 17 // Normally, version-negotiation (if enabled) would not happen until 18 // the API request is made. 19 cli.checkVersion(ctx) 20 if versions.GreaterThanOrEqualTo(cli.version, "1.25") { 21 query.Set("force", "1") 22 } 23 } 24 resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil) 25 defer ensureReaderClosed(resp) 26 return err 27 }