containerutils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ContainerDir = filepath.Join(utils.GetLilipodHome(), "containers")

ContainerDir is the default location for downloaded images.

Functions

func CreateRootfs

func CreateRootfs(image string, name string, createConfig utils.Config, uid, gid string) error

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

func Exec(pid int, interactive bool, tty bool, config utils.Config) error

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

func GetDir(name string) string

GetDir returns the path on the filesystem where container's rootfs and config is located.

func GetID

func GetID(name string) string

GetID returns the md5sum based ID for given container. If a recognized ID is passed, it is returned.

func GetPid

func GetPid(id string) (int, error)

GetPid will return the pid of the process running the container with input id.

func GetRandomName

func GetRandomName() string

GetRandomName returns a 12 string char of random characters. Generated name will be like example_test12.

func GetRootfsDir

func GetRootfsDir(name string) string

GetRootfsDir returns the path on the filesystem where container's rootfs is located.

func Inspect

func Inspect(containers []string, size bool, format string) (string, error)

Inspect will return a JSON or a formatted string describing the input containers.

func IsRunning

func IsRunning(name string) bool

IsRunning returns whether the container name or id is running or not.

func PivotRoot

func PivotRoot(path string) error

PivotRoot will perform pivot root syscall into path.

func Rename

func Rename(oldContainer string, newContainer string) error

Rename will change the name of oldContainer to newContainer.

func RunContainer

func RunContainer(tty bool, conf utils.Config) error

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

func SetupRootfs(conf utils.Config) error

SetupRootfs will set up the rootfs defined in conf into path. This will also populate container's /run/.containerenv.

func Start

func Start(interactive, tty bool, config utils.Config) error

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.

func Stop

func Stop(name string, force bool, timeout int, signal string) error

Stop will find all the processes in given container and will stop them.

Types

This section is empty.

Jump to

Keyboard shortcuts

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