github.com/kinvolk/docker@v1.13.1/client/volume_create.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 6 "github.com/docker/docker/api/types" 7 volumetypes "github.com/docker/docker/api/types/volume" 8 "golang.org/x/net/context" 9 ) 10 11 // VolumeCreate creates a volume in the docker host. 12 func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) { 13 var volume types.Volume 14 resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) 15 if err != nil { 16 return volume, err 17 } 18 err = json.NewDecoder(resp.body).Decode(&volume) 19 ensureReaderClosed(resp) 20 return volume, err 21 }