mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
27 lines
615 B
Go
27 lines
615 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// NetworkDisconnect disconnects a container from an existent network in the docker host.
|
|
func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error {
|
|
networkID, err := trimID("network", networkID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
containerID, err = trimID("container", containerID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
nd := NetworkDisconnectOptions{
|
|
Container: containerID,
|
|
Force: force,
|
|
}
|
|
resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil)
|
|
defer ensureReaderClosed(resp)
|
|
return err
|
|
}
|