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 (
|
|
|
|
"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
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// VolumeCreate creates a volume in the docker host.
|
2016-10-06 12:57:17 -04:00
|
|
|
func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (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
|
|
|
|
}
|