container_stop.go 501 B

12345678910111213141516171819
  1. package client
  2. import (
  3. "net/url"
  4. "strconv"
  5. "golang.org/x/net/context"
  6. )
  7. // ContainerStop stops a container without terminating the process.
  8. // The process is blocked until the container stops or the timeout expires.
  9. func (cli *Client) ContainerStop(ctx context.Context, containerID string, timeout int) error {
  10. query := url.Values{}
  11. query.Set("t", strconv.Itoa(timeout))
  12. resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil)
  13. ensureReaderClosed(resp)
  14. return err
  15. }