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