Documentation ¶
Overview ¶
Package containerutils contains helpers and utilities for managing and creating containers.
Package containerutils contains helpers and utilities for managing and creating containers.
Index ¶
- Variables
- func CreateRootfs(image string, name string, createConfig utils.Config, uid, gid string) error
- func Exec(pid int, interactive bool, tty bool, config utils.Config) error
- func GetContainerInfo(container string, size bool, filters map[string]string) (*utils.Config, error)
- func GetDir(name string) string
- func GetID(name string) string
- func GetPid(id string) (int, error)
- func GetRandomName() string
- func GetRootfsDir(name string) string
- func Inspect(containers []string, size bool, format string) (string, error)
- func IsRunning(name string) bool
- func PivotRoot(path string) error
- func Rename(oldContainer string, newContainer string) error
- func RunContainer(tty bool, conf utils.Config) error
- func SetupRootfs(conf utils.Config) error
- func Start(interactive, tty bool, config utils.Config) error
- func Stop(name string, force bool, timeout int, signal string) error
Constants ¶
This section is empty.
Variables ¶
var ContainerDir = filepath.Join(utils.GetLilipodHome(), "containers")
ContainerDir is the default location for downloaded images.
Functions ¶
func CreateRootfs ¶
CreateRootfs will generate a chrootable rootfs from input oci image reference, with input name and config. If input image is not found it will be automatically pulled. This function will read the oci-image manifest and properly unpack the layers in the right order to generate a valid rootfs. Untarring process will follow the keep-id option if specified in order to ensure no permission problems. Generated config will be saved inside the container's dir. This will NOT be an oci-compatible container config.
func Exec ¶
Exec will enter the namespace of target container and execute the command needed. This function will setup an nsenter command, that will connect to the container's namespace.
func GetContainerInfo ¶
func GetContainerInfo( container string, size bool, filters map[string]string, ) (*utils.Config, error)
GetContainerInfo returns the Config of input container's name or id. Additional input variables can be used for filters and size info.
func GetDir ¶
GetDir returns the path on the filesystem where container's rootfs and config is located.
func GetID ¶
GetID returns the md5sum based ID for given container. If a recognized ID is passed, it is returned.
func GetRandomName ¶
func GetRandomName() string
GetRandomName returns a 12 string char of random characters. Generated name will be like example_test12.
func GetRootfsDir ¶
GetRootfsDir returns the path on the filesystem where container's rootfs is located.
func RunContainer ¶
RunContainer will start specified container in path, with tty if enabled. This will:
- SetupRootfs
- PivotRoot
- Set Hostname according to input config
- Set UID/GID according to input config
- execve the entrypoint
func SetupRootfs ¶
SetupRootfs will set up the rootfs defined in conf into path. This will also populate container's /run/.containerenv.
func Start ¶
Start will enter the target container. If tty is specified, the container will be started in interactive mode with full shell. If interactive only is specified, container will be started in interactive mode, but only stdin will be forwarded. Else the container will be started in background and all output will be saved in the logs.
Types ¶
This section is empty.