2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-09-06 18:46:37 +00:00
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
2016-10-14 20:20:13 +00:00
|
|
|
volumetypes "github.com/docker/docker/api/types/volume"
|
2016-09-06 18:46:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// VolumeCreate creates a volume in the docker host.
|
2018-05-14 15:03:48 +00:00
|
|
|
func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) {
|
2016-09-06 18:46:37 +00:00
|
|
|
var volume types.Volume
|
|
|
|
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
|
2019-02-11 12:26:12 +00:00
|
|
|
defer ensureReaderClosed(resp)
|
2016-09-06 18:46:37 +00:00
|
|
|
if err != nil {
|
|
|
|
return volume, err
|
|
|
|
}
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&volume)
|
|
|
|
return volume, err
|
|
|
|
}
|