container_restart.go 477 B

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