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