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"
|
|
|
|
|
2022-03-18 11:33:43 -04:00
|
|
|
"github.com/docker/docker/api/types/volume"
|
2016-09-06 14:46:37 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// VolumeCreate creates a volume in the docker host.
|
2022-03-05 17:25:55 -05:00
|
|
|
func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
|
2022-03-18 11:33:43 -04:00
|
|
|
var vol volume.Volume
|
2016-09-06 14:46:37 -04:00
|
|
|
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
|
2019-02-11 07:26:12 -05:00
|
|
|
defer ensureReaderClosed(resp)
|
2016-09-06 14:46:37 -04:00
|
|
|
if err != nil {
|
2022-03-18 11:33:43 -04:00
|
|
|
return vol, err
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
2022-03-18 11:33:43 -04:00
|
|
|
err = json.NewDecoder(resp.body).Decode(&vol)
|
|
|
|
return vol, err
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|