container_restart.go 536 B

1234567891011121314151617181920
  1. package client
  2. import (
  3. "net/url"
  4. "strconv"
  5. "golang.org/x/net/context"
  6. )
  7. // ContainerRestart stops and starts a container again.
  8. // It makes the daemon to wait for the container to be up again for
  9. // a specific amount of time, given the timeout.
  10. func (cli *Client) ContainerRestart(ctx context.Context, containerID string, timeout int) error {
  11. query := url.Values{}
  12. query.Set("t", strconv.Itoa(timeout))
  13. resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil)
  14. ensureReaderClosed(resp)
  15. return err
  16. }