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"
|
|
|
|
|
2022-03-18 15:33:43 +00:00
|
|
|
"github.com/docker/docker/api/types/volume"
|
2016-09-06 18:46:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// VolumeCreate creates a volume in the docker host.
|
2022-03-05 22:25:55 +00:00
|
|
|
func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
|
2022-03-18 15:33:43 +00:00
|
|
|
var vol volume.Volume
|
2016-09-06 18:46:37 +00:00
|
|
|
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 {
|
2022-03-18 15:33:43 +00:00
|
|
|
return vol, err
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
2022-03-18 15:33:43 +00:00
|
|
|
err = json.NewDecoder(resp.body).Decode(&vol)
|
|
|
|
return vol, err
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|