github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/client/container_restart.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "net/url" 6 "time" 7 8 timetypes "github.com/docker/docker/api/types/time" 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 }