github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/client/network_connect.go (about)

     1  package client
     2  
     3  import (
     4  	"github.com/docker/docker/api/types"
     5  	"github.com/docker/docker/api/types/network"
     6  	"golang.org/x/net/context"
     7  )
     8  
     9  // NetworkConnect connects a container to an existent network in the docker host.
    10  func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error {
    11  	nc := types.NetworkConnect{
    12  		Container:      containerID,
    13  		EndpointConfig: config,
    14  	}
    15  	resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, nc, nil)
    16  	ensureReaderClosed(resp)
    17  	return err
    18  }