package runhcs

import "github.com/Microsoft/hcsshim/pkg/go-runhcs"

Index

Types

type ContainerState

type ContainerState = irunhcs.ContainerState

ContainerState is the representation of the containers state at the moment of query.

type CreateOpts

type CreateOpts struct {
	runc.IO
	// PidFile is the path to the file to write the process id to.
	PidFile string
	// ShimLog is the path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-shim-log) for the launched shim process.
	ShimLog string
	// VMLog is the path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-vm-log) for the launched VM shim process.
	VMLog string
	// VMConsole is the path to the pipe for the VM's console (e.g. \\.\pipe\debugpipe)
	VMConsole string
}

CreateOpts is set of options that can be used with the Create command.

type CreateScratchOpts

type CreateScratchOpts struct {
	// SizeGB is the size in GB of the scratch file to create.
	SizeGB int
	// CacheFile is the path to an existing `scratch.vhx` to copy. If
	// `CacheFile` does not exit the scratch will be created.
	CacheFile string
	// UseVirtualMemory indicates whether the UVM used to create the
	// scratch should be backed with virtual memory or not.
	UseVirtualMemory bool
}

CreateScratchOpts is the set of options that can be used with the `CreateScratchWithOpts` command.

type DeleteOpts

type DeleteOpts struct {
	// Force forcibly deletes the container if it is still running (uses SIGKILL).
	Force bool
}

DeleteOpts is set of options that can be used with the Delete command.

type ExecOpts

type ExecOpts struct {
	runc.IO
	// Detach from the container's process.
	Detach bool
	// PidFile is the path to the file to write the process id to.
	PidFile string
	// ShimLog is the path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-<exec-id>-log) for the launched shim process.
	ShimLog string
}

ExecOpts is set of options that can be used with the Exec command.

type Format

type Format string

Format is the type of log formatting options available.

const (

	// Text is the default text log output.
	Text Format = "text"
	// JSON is the JSON formatted log output.
	JSON Format = "json"
)

type ResizeTTYOpts

type ResizeTTYOpts struct {
	// Pid is the process pid (defaults to init pid).
	Pid *int
}

ResizeTTYOpts is set of options that can be used with the ResizeTTY command.

type Runhcs

type Runhcs struct {
	// Debug enables debug output for logging.
	Debug bool
	// Log sets the log file path or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-log) where internal debug information is written.
	Log string
	// LogFormat sets the format used by logs.
	LogFormat Format
	// Owner sets the compute system owner property.
	Owner string
	// Root is the registry key root for storage of runhcs container state.
	Root string
}

Runhcs is the client to the runhcs cli.

func (*Runhcs) Create

func (r *Runhcs) Create(ctx context.Context, id, bundle string, opts *CreateOpts) error

Create creates a new container and returns its pid if it was created successfully.

func (*Runhcs) CreateScratch

func (r *Runhcs) CreateScratch(ctx context.Context, destpath string) error

CreateScratch creates a scratch vhdx at 'destpath' that is ext4 formatted.

func (*Runhcs) CreateScratchWithOpts

func (r *Runhcs) CreateScratchWithOpts(ctx context.Context, destpath string, opts *CreateScratchOpts) error

CreateScratchWithOpts creates a scratch vhdx at 'destpath' that is ext4 formatted based on `opts`.

func (*Runhcs) Delete

func (r *Runhcs) Delete(ctx context.Context, id string, opts *DeleteOpts) error

Delete any resources held by the container often used with detached containers.

func (*Runhcs) Exec

func (r *Runhcs) Exec(ctx context.Context, id, processFile string, opts *ExecOpts) error

Exec executes an additional process inside the container based on the oci.Process spec found at processFile.

func (*Runhcs) Kill

func (r *Runhcs) Kill(ctx context.Context, id, signal string) error

Kill sends the specified signal (default: SIGTERM) to the container's init process.

func (*Runhcs) List

func (r *Runhcs) List(ctx context.Context) ([]*ContainerState, error)

List containers started by runhcs.

Note: This is specific to the Runhcs.Root namespace provided in the global settings.

func (*Runhcs) Pause

func (r *Runhcs) Pause(ctx context.Context, id string) error

Pause suspends all processes inside the container.

func (*Runhcs) Ps

func (r *Runhcs) Ps(ctx context.Context, id string) ([]int, error)

Ps displays the processes running inside a container.

func (*Runhcs) ResizeTTY

func (r *Runhcs) ResizeTTY(ctx context.Context, id string, width, height uint16, opts *ResizeTTYOpts) error

ResizeTTY updates the terminal size for a container process.

func (*Runhcs) Resume

func (r *Runhcs) Resume(ctx context.Context, id string) error

Resume resumes all processes that have been previously paused.

func (*Runhcs) Start

func (r *Runhcs) Start(ctx context.Context, id string) error

Start will start an already created container.

func (*Runhcs) State

func (r *Runhcs) State(ctx context.Context, id string) (*ContainerState, error)

State outputs the state of a container.

Source Files

doc.go runhcs.go runhcs_create-scratch.go runhcs_create.go runhcs_delete.go runhcs_exec.go runhcs_kill.go runhcs_list.go runhcs_pause.go runhcs_ps.go runhcs_resize-tty.go runhcs_resume.go runhcs_start.go runhcs_state.go

Version
v0.13.0 (latest)
Published
Apr 21, 2025
Platform
windows/amd64
Imports
14 packages
Last checked
1 hour ago

Tools for package owners.