github.com/moby/docker@v26.1.3+incompatible/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/volume"
     8  )
     9  
    10  // VolumeCreate creates a volume in the docker host.
    11  func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
    12  	var vol volume.Volume
    13  	resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
    14  	defer ensureReaderClosed(resp)
    15  	if err != nil {
    16  		return vol, err
    17  	}
    18  	err = json.NewDecoder(resp.body).Decode(&vol)
    19  	return vol, err
    20  }