runc

package
v1.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NamespacesExists

func NamespacesExists(ctx context.Context, namespaces []LinuxNamespace, nsType ...specs.LinuxNamespaceType) error

func RefreshNamespace

func RefreshNamespace(ctx context.Context, ns *LinuxNamespace)

func RefreshNamespaces

func RefreshNamespaces(ctx context.Context, namespaces []LinuxNamespace, nsType ...specs.LinuxNamespaceType)

func RootCommandContext

func RootCommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd

Types

type BackgroundState

type BackgroundState struct {
	// contains filtered or unexported fields
}

func RunBundleInBackground

func RunBundleInBackground(ctx context.Context, runc Runc, bundle ContainerBundle) (*BackgroundState, error)

func (*BackgroundState) Exited

func (r *BackgroundState) Exited() (bool, error)

func (*BackgroundState) Wait

func (r *BackgroundState) Wait()

type Config

type Config struct {
	Root          string `json:"root" split_words:"true" required:"false"`
	Debug         bool   `json:"debug" split_words:"true" required:"false"`
	SystemdCgroup bool   `json:"systemdCgroup" split_words:"true" required:"false"`
	Rootless      string `json:"rootless" split_words:"true" required:"false"`
	NsmountPath   string `json:"nsmountPath" split_words:"true" default:"nsmount"`
}

func ConfigFromEnvironment

func ConfigFromEnvironment() Config

type ContainerBundle

type ContainerBundle interface {
	EditSpec(ctx context.Context, editors ...SpecEditor) error
	MountFromProcess(ctx context.Context, fromPid int, fromPath, mountpoint string) error
	CopyFileFromProcess(ctx context.Context, pid int, fromPath, toPath string) error
	Path() string
	ContainerId() string
	Remove() error
}

type ContainerState

type ContainerState struct {
	ID          string            `json:"id"`
	Pid         int               `json:"pid"`
	Status      string            `json:"status"`
	Bundle      string            `json:"bundle"`
	Rootfs      string            `json:"rootfs"`
	Created     time.Time         `json:"created"`
	Annotations map[string]string `json:"annotations"`
}

type IoOpts

type IoOpts struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

func (IoOpts) WithStdin

func (o IoOpts) WithStdin(reader io.Reader) IoOpts

type LinuxNamespace

type LinuxNamespace struct {
	Type  specs.LinuxNamespaceType
	Path  string
	Inode uint64
}

func FilterNamespaces

func FilterNamespaces(ns []LinuxNamespace, types ...specs.LinuxNamespaceType) []LinuxNamespace

type LinuxProcessInfo

type LinuxProcessInfo struct {
	Pid        int
	Namespaces []LinuxNamespace
	CGroupPath string
}

func ReadLinuxProcessInfo

func ReadLinuxProcessInfo(ctx context.Context, pid int) (LinuxProcessInfo, error)

type Runc

type Runc interface {
	State(ctx context.Context, id string) (*ContainerState, error)
	Create(ctx context.Context, image, id string) (ContainerBundle, error)
	Run(ctx context.Context, container ContainerBundle, ioOpts IoOpts) error
	RunCommand(ctx context.Context, container ContainerBundle) (*exec.Cmd, error)
	Delete(ctx context.Context, id string, force bool) error
	Kill(background context.Context, id string, signal syscall.Signal) error
}

func NewRunc

func NewRunc(cfg Config) Runc

type SpecEditor

type SpecEditor func(spec *specs.Spec)

func WithAnnotations

func WithAnnotations(annotations map[string]string) SpecEditor

func WithCapabilities

func WithCapabilities(caps ...string) SpecEditor

func WithCgroupPath

func WithCgroupPath(cgroupPath, child string) SpecEditor

func WithHostname

func WithHostname(hostname string) SpecEditor

func WithMountIfNotPresent

func WithMountIfNotPresent(mount specs.Mount) SpecEditor

func WithNamespace

func WithNamespace(ns LinuxNamespace) SpecEditor

func WithNamespaces

func WithNamespaces(ns []LinuxNamespace) SpecEditor

func WithProcessArgs

func WithProcessArgs(args ...string) SpecEditor

func WithProcessCwd

func WithProcessCwd(cwd string) SpecEditor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL