Files
moby/client/volume_create.go
Derek McGowan afd6487b2e Create github.com/moby/moby/api module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-21 09:30:05 -07:00

22 lines
497 B
Go

package client
import (
"context"
"encoding/json"
"github.com/moby/moby/api/types/volume"
)
// VolumeCreate creates a volume in the docker host.
func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
defer ensureReaderClosed(resp)
if err != nil {
return volume.Volume{}, err
}
var vol volume.Volume
err = json.NewDecoder(resp.Body).Decode(&vol)
return vol, err
}