gopkg.in/docker/docker.v20@v20.10.27/client/volume_create.go (about)

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