// StopContainer stops a hyper container
StopContainer stops a hyper container
// StopContainer stops a hyper container
func (c *Client) StopContainer(containerID string, timeout int64) error {
	ctxTimeout := time.Duration(timeout) * time.Second
	if ctxTimeout < hyperContextTimeout {
		ctxTimeout = hyperContextTimeout
	} else {
		ctxTimeout += time.Duration(5) * time.Second
	}
	isRunning, err := isContainerRunning(c, containerID)
	if err != nil {
		return err
	}
	if !isRunning {
		glog.V(3).Infof("Container %q is already stopped, skip", containerID)
		return nil
	}
	ctx, cancel := getContextWithTimeout(ctxTimeout)
	defer cancel()
	_, err = c.client.ContainerStop(ctx, &types.ContainerStopRequest{
		ContainerID: containerID,
		Timeout:     timeout,
	})
	return err
}
func ( c * Client ) StopContainer ( containerID string , timeout int64 ) error { ctxTimeout := time . Duration ( timeout ) * time . Second if ctxTimeout < hyperContextTimeout { ctxTimeout = hyperContextTimeout } else { ctxTimeout += time . Duration ( 5 ) * time . Second } isRunning , err := isContainerRunning ( c , containerID ) if err != nil { return err } if ! isRunning { glog . V ( 3 ) . Infof ( " " , containerID ) return nil } ctx , cancel := getContextWithTimeout ( ctxTimeout ) defer cancel ( ) _ , err = c . client . ContainerStop ( ctx , & types . ContainerStopRequest { ContainerID : containerID , Timeout : timeout , } ) return err }
StopContainer stops a hyper container
StopContainer stops a hyper container
// extend 5s give hyperd enough time to response if timeout // do checks about container status