github.com/brandon-bethke-neudesic/moby@v1.13.1/client/container_stop.go (about)

     1  package client
     2  
     3  import (
     4  	"net/url"
     5  	"time"
     6  
     7  	timetypes "github.com/docker/docker/api/types/time"
     8  	"golang.org/x/net/context"
     9  )
    10  
    11  // ContainerStop stops a container without terminating the process.
    12  // The process is blocked until the container stops or the timeout expires.
    13  func (cli *Client) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error {
    14  	query := url.Values{}
    15  	if timeout != nil {
    16  		query.Set("t", timetypes.DurationToSecondsString(*timeout))
    17  	}
    18  	resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil)
    19  	ensureReaderClosed(resp)
    20  	return err
    21  }