示例#1
0
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
func (ds *dockerService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
	if ds.streamingServer == nil {
		return nil, streaming.ErrorStreamingDisabled("exec")
	}
	_, err := checkContainerStatus(ds.client, req.GetContainerId())
	if err != nil {
		return nil, err
	}
	return ds.streamingServer.GetExec(req)
}
示例#2
0
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
func (ds *dockerService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
	if ds.streamingServer == nil {
		return nil, streaming.ErrorStreamingDisabled("attach")
	}
	container, err := checkContainerStatus(ds.client, req.GetContainerId())
	if err != nil {
		return nil, err
	}
	tty := container.Config.Tty
	return ds.streamingServer.GetAttach(req, tty)
}
示例#3
0
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
func (ds *dockerService) PortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
	if ds.streamingServer == nil {
		return nil, streaming.ErrorStreamingDisabled("port forward")
	}
	_, err := checkContainerStatus(ds.client, req.GetPodSandboxId())
	if err != nil {
		return nil, err
	}
	// TODO(timstclair): Verify that ports are exposed.
	return ds.streamingServer.GetPortForward(req)
}