launch

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 46 Imported by: 0

Documentation

Overview

Package launcher is responsible for starting a container, with configuration passed to it from the CLI layer.

The package currently implements a single Launcher, with an Exec method that constructs a runtime configuration and calls the Apptainer runtime starter binary to start the container.

TODO - the launcher package will be extended to support launching containers via the OCI runc/crun runtime, in addition to the current Apptainer runtime starter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Launcher

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

func NewLauncher

func NewLauncher(opts ...Option) (*Launcher, error)

func (*Launcher) Exec

func (l *Launcher) Exec(ctx context.Context, image string, args []string, instanceName string) error

Exec prepares an EngineConfig defining how a container should be launched, then calls the starter binary to execute it. This includes interactive containers, instances, and joining an existing instance.

func (*Launcher) SetCheckpointConfig

func (l *Launcher) SetCheckpointConfig() error

SetCheckpointConfig sets EngineConfig entries to bind the provided list of libs and bins.

func (*Launcher) SetGPUConfig

func (l *Launcher) SetGPUConfig() error

SetGPUConfig sets up EngineConfig entries for NV / ROCm usage, if requested.

type Namespaces

type Namespaces struct {
	User bool
	UTS  bool
	PID  bool
	IPC  bool
	Net  bool
	// NoPID will force the PID namespace not to be used, even if set by default / other flags.
	NoPID bool
}

Namespaces holds flags for the optional (non-mount) namespaces that can be requested for a container launch.

type Option

type Option func(co *launchOptions) error

func OptAllowSUID

func OptAllowSUID(b bool) Option

OptAllowSUID permits setuid executables inside a container started by the root user.

func OptAppName

func OptAppName(a string) Option

OptAppName sets a SCIF application name to run.

func OptBoot

func OptBoot(b bool) Option

OptBoot enables execution of /sbin/init on startup of an instance container.

func OptCacheDisabled

func OptCacheDisabled(b bool) Option

CacheDisabled indicates caching of images was disabled in the CLI.

func OptCaps

func OptCaps(add, drop string) Option

OptCaps sets capabilities to add and drop.

func OptCgroupsJSON

func OptCgroupsJSON(cj string) Option

OptCgroupsJSON sets a Cgroups resource limit configuration to apply to the container.

func OptConfigFile

func OptConfigFile(c string) Option

OptConfigFile specifies an alternate apptainer.conf that will be used by unprivileged installations only.

func OptContain

func OptContain(b bool) Option

OptContain starts the container with minimal /dev and empty home/tmp mounts.

func OptContainAll

func OptContainAll(b bool) Option

OptContainAll infers Contain, and adds PID, IPC namespaces, and CleanEnv.

func OptContainLibs

func OptContainLibs(cl []string) Option

OptContainLibs mounts specified libraries into the container .singularity.d/libs dir.

func OptCwdPath added in v1.3.0

func OptCwdPath(p string) Option

OptCwdPath specifies the initial working directory in the container.

func OptDMTCPLaunch

func OptDMTCPLaunch(a string) Option

OptDMTCPLaunch

func OptDMTCPRestart

func OptDMTCPRestart(a string) Option

OptDMTCPRestart

func OptDNS

func OptDNS(d string) Option

OptDNS sets a DNS entry for the container resolv.conf.

func OptEnv

func OptEnv(env map[string]string, envFile string, clean bool) Option

OptEnv sets container environment

envFile is a path to a file container environment variables to set. env is a map of name=value env vars to set. clean removes host variables from the container environment.

func OptFakeroot

func OptFakeroot(b bool) Option

OptFakeroot enables the fake root mode, using user namespaces and subuid / subgid mapping.

func OptHome

func OptHome(homeDir string, custom bool, disable bool) Option

OptHome sets the home directory configuration for the container.

homeDir is the path or src:dst to bind mount. custom is a marker that this is user supplied, and must not be overridden. disable will disable the home mount entirely, ignoring other options.

func OptHostname

func OptHostname(h string) Option

OptHostname sets a hostname for the container (infers/requires UTS namespace).

func OptIgnoreFakerootCmd

func OptIgnoreFakerootCmd(b bool) Option

OptIgnoreFakerootCmd

func OptIgnoreSubuid

func OptIgnoreSubuid(b bool) Option

OptIgnoreSubuid

func OptIgnoreUserns

func OptIgnoreUserns(b bool) Option

OptIgnoreUserns

func OptKeepPrivs

func OptKeepPrivs(b bool) Option

OptKeepPrivs keeps all privileges inside a container started by the root user.

func OptKeyInfo

func OptKeyInfo(ki *cryptkey.KeyInfo) Option

OptKeyInfo sets encryption key material to use when accessing an encrypted container image.

func OptMounts

func OptMounts(binds []string, mounts []string, fuseMounts []string) Option

OptMounts sets user-requested mounts to propagate into the container.

binds lists bind mount specifications in Apptainer's <src>:<dst>[:<opts>] format. mounts lists bind mount specifications in Docker CSV processed format. fuseMounts list FUSE mounts in <type>:<fuse command> <mountpoint> format.

func OptNamespaces

func OptNamespaces(n Namespaces) Option

OptNamespaces enable the individual kernel-support namespaces for the container.

func OptNetwork

func OptNetwork(network string, args []string) Option

OptNetwork enables CNI networking.

network is the name of the CNI configuration to enable. args are arguments to pass to the CNI plugin.

func OptNoEval

func OptNoEval(b bool) Option

OptNoEval disables shell evaluation of args and env vars.

func OptNoInit

func OptNoInit(b bool) Option

OptNoInit disables shim process when PID namespace is used.

func OptNoMount

func OptNoMount(nm []string) Option

OptNoMount disables the specified bind mounts.

func OptNoNvidia

func OptNoNvidia(b bool) Option

OptNoNvidia disables NVIDIA GPU support, even if enabled via apptainer.conf.

func OptNoPrivs

func OptNoPrivs(b bool) Option

OptNoPrivs drops all privileges inside a container.

func OptNoRocm

func OptNoRocm(b bool) Option

OptNoRocm disables Rocm GPU support, even if enabled via apptainer.conf.

func OptNoUmask

func OptNoUmask(b bool) Option

OptNoUmask disables propagation of the host umask into the container, using a default 0022.

func OptNvidia

func OptNvidia(nv bool, nvccli bool) Option

OptNvidia enables NVIDIA GPU support.

nvccli sets whether to use the nvidia-container-runtime (true), or legacy bind mounts (false).

func OptOverlayPaths

func OptOverlayPaths(op []string) Option

OptOverlayPaths sets overlay images and directories to apply to the container.

func OptRocm

func OptRocm(b bool) Option

OptRocm enable Rocm GPU support.

func OptRunscriptTimeout added in v1.3.1

func OptRunscriptTimeout(timeout string) Option

OptRunscriptTimeout

func OptScratchDirs

func OptScratchDirs(sd []string) Option

OptScratchDirs sets temporary host directories to create and bind into the container.

func OptSecurity

func OptSecurity(s []string) Option

OptSecurity supplies a list of security options (selinux, apparmor, seccomp) to apply.

func OptShareNSFd added in v1.3.0

func OptShareNSFd(fd int) Option

OptShareNSFd

func OptShareNSMode added in v1.3.0

func OptShareNSMode(b bool) Option

OptShareNSMode

func OptShellPath

func OptShellPath(s string) Option

OptShellPath specifies a custom shell executable to be launched in the container.

func OptTmpDir

func OptTmpDir(a string) Option

OptTmpDir

func OptUnderlay

func OptUnderlay(b bool) Option

OptUnderlay

func OptUnsquash

func OptUnsquash(b bool) Option

OptUnsquash

func OptUseBuildConfig

func OptUseBuildConfig(b bool) Option

OptUseBuildConfig

func OptWorkDir

func OptWorkDir(wd string) Option

OptWorkDir sets the parent path for scratch directories, and contained home/tmp on the host.

func OptWritable

func OptWritable(b bool) Option

OptWritable sets the container image to be writable.

func OptWritableTmpfs

func OptWritableTmpfs(b bool) Option

OptWritableTmpFs applies an ephemeral writable overlay to the container.

Jump to

Keyboard shortcuts

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