network_create.go 560 B

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