github.com/mforkel/docker-ce-i386@v17.12.1-ce-rc2+incompatible/components/engine/client/container_restart.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  // ContainerRestart stops and starts a container again.
    12  // It makes the daemon to wait for the container to be up again for
    13  // a specific amount of time, given the timeout.
    14  func (cli *Client) ContainerRestart(ctx context.Context, containerID string, timeout *time.Duration) error {
    15  	query := url.Values{}
    16  	if timeout != nil {
    17  		query.Set("t", timetypes.DurationToSecondsString(*timeout))
    18  	}
    19  	resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil)
    20  	ensureReaderClosed(resp)
    21  	return err
    22  }