github.com/brandon-bethke-neudesic/moby@v1.13.1/client/network_create.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 6 "github.com/docker/docker/api/types" 7 "golang.org/x/net/context" 8 ) 9 10 // NetworkCreate creates a new network in the docker host. 11 func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { 12 networkCreateRequest := types.NetworkCreateRequest{ 13 NetworkCreate: options, 14 Name: name, 15 } 16 var response types.NetworkCreateResponse 17 serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil) 18 if err != nil { 19 return response, err 20 } 21 22 json.NewDecoder(serverResp.body).Decode(&response) 23 ensureReaderClosed(serverResp) 24 return response, err 25 }