container

package
v0.0.0-...-50ffc52 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCGroupPath = "/box"
	MB                = 1 << 20
)
View Source
const (
	DigestStdLen = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Config   *v1.Config
	Digest   string
	RootFS   string
	Pids     []int
	Publish  []string
	Volumes  []string
	Hostname string
	Network  string
	IP       string
	// contains filtered or unexported fields
}

func GetAllContainers

func GetAllContainers() ([]*Container, error)

GetAllContainers returns slice of running Containers.

func GetContainerByDigest

func GetContainerByDigest(digest string) (*Container, error)

GetContainerByDigest returns a Container associate with a digest.

func NewContainer

func NewContainer() *Container

/ NewContainer returns a new Container with a random digest.

func (*Container) GetIP

func (c *Container) GetIP() (net.IP, network.Releaser, error)

func (*Container) GetPids

func (c *Container) GetPids() ([]int, error)

GetPids returns slice of pid running inside Container.

NOTE: First element [0], is the fork process.

func (*Container) Kill

func (c *Container) Kill() error

Kill kills the Container.

func (*Container) LoadCGroups

func (c *Container) LoadCGroups(pid int) error

LoadCGroups loads CGroups for container.

func (*Container) LoadConfig

func (c *Container) LoadConfig() error

LoadConfig loads and sets Container Config from its image config file.

func (*Container) LogFile

func (c *Container) LogFile() string

LogFile returns a path to the container logfile

func (*Container) MountFromImage

func (c *Container) MountFromImage(img *image.Image) (filesystem.Unmounter, error)

MountFromImage mounts filesystem for Container from an Image. It uses overlayFS for union mount of multiple layers.

func (*Container) Remove

func (c *Container) Remove() error

Remove removes Container directory. It only works if all mount points have unmounted.

func (*Container) SetCPULimit

func (c *Container) SetCPULimit(cpus int) *Container

SetCPULimit sets Container number of CPU shares (relative weight).

func (*Container) SetHostname

func (c *Container) SetHostname()

SetHostname sets Hostname for container.

If Hostname was empty it uses the digest[:12]

func (*Container) SetMemorySwapLimit

func (c *Container) SetMemorySwapLimit(memory, swap int) *Container

SetMemorySwapLimit sets Container's memory and swap limitation in MegaByte.

func (*Container) SetNetworkNamespace

func (c *Container) SetNetworkNamespace() (network.Unsetter, error)

func (*Container) SetPorts

func (c *Container) SetPorts(ports string)

func (*Container) SetProcessLimit

func (c *Container) SetProcessLimit(pids int) *Container

SetProcessLimit sets maximum simultaneous process for Container.

func (*Container) SetupNetwork

func (c *Container) SetupNetwork(bridge string) (filesystem.Unmounter, error)

func (*Container) SetupPortmap

func (c *Container) SetupPortmap() (nat.Unmapper, error)

func (*Container) Stop

func (c *Container) Stop() error

Stop stops the Container.

Jump to

Keyboard shortcuts

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