volume_create.go 507 B

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