lxc

package
v0.0.0-...-ab10d8f Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2016 License: Apache-2.0, LGPL-2.1 Imports: 12 Imported by: 0

README

Go Bindings for LXC (Linux Containers)

This package implements Go bindings for the LXC C API (liblxc).

Requirements

This package requires LXC 1.x and its development package to be installed. Works with Go 1.x.

Installing

To install it, run:

go get gopkg.in/lxc/go-lxc.v2

Documentation

Documentation can be found at GoDoc.

Stability

The package API will remain stable as described in gopkg.in.

Examples

See the examples directory for some.

Contributing

We'd love to see go-lxc improve. To contribute to go-lxc;

  • Fork the repository
  • Modify your fork
  • Ensure your fork passes all tests
  • Send a pull request
    • Bonus points if the pull request includes what you changed, why you changed it, and tests attached.
    • For the love of all that is holy, please use go fmt before you send the pull request.

We'll review it and merge it in if it's appropriate.

Documentation

Overview

Package lxc provides Go Bindings for LXC (Linux Containers) C API.

LXC (LinuX Containers) is an operating system–level virtualization method for running multiple isolated Linux systems (containers) on a single control host.

LXC combines cgroups and namespace support to provide an isolated environment for applications.

Index

Constants

View Source
const (
	MIGRATE_PRE_DUMP = 0
	MIGRATE_DUMP     = 1
	MIGRATE_RESTORE  = 2
)

Variables

View Source
var (
	ErrAddDeviceNodeFailed           = NewError("adding device to container failed")
	ErrAllocationFailed              = NewError("allocating memory failed")
	ErrAlreadyDefined                = NewError("container already defined")
	ErrAlreadyFrozen                 = NewError("container is already frozen")
	ErrAlreadyRunning                = NewError("container is already running")
	ErrAttachFailed                  = NewError("attaching to the container failed")
	ErrAttachInterfaceFailed         = NewError("attaching specified netdev to the container failed")
	ErrBlkioUsage                    = NewError("BlkioUsage for the container failed")
	ErrCheckpointFailed              = NewError("checkpoint failed")
	ErrClearingCgroupItemFailed      = NewError("clearing cgroup item for the container failed")
	ErrCloneFailed                   = NewError("cloning the container failed")
	ErrCloseAllFdsFailed             = NewError("setting close_all_fds flag for container failed")
	ErrCreateFailed                  = NewError("creating the container failed")
	ErrCreateSnapshotFailed          = NewError("snapshotting the container failed")
	ErrDaemonizeFailed               = NewError("setting daemonize flag for container failed")
	ErrDestroyAllSnapshotsFailed     = NewError("destroying all snapshots failed")
	ErrDestroyFailed                 = NewError("destroying the container failed")
	ErrDestroySnapshotFailed         = NewError("destroying the snapshot failed")
	ErrDestroyWithAllSnapshotsFailed = NewError("destroying the container with all snapshots failed")
	ErrDetachInterfaceFailed         = NewError("detaching specified netdev to the container failed")
	ErrExecuteFailed                 = NewError("executing the command in a temporary container failed")
	ErrFreezeFailed                  = NewError("freezing the container failed")
	ErrInsufficientNumberOfArguments = NewError("insufficient number of arguments were supplied")
	ErrInterfaces                    = NewError("getting interface names for the container failed")
	ErrIPAddresses                   = NewError("getting IP addresses of the container failed")
	ErrIPAddress                     = NewError("getting IP address on the interface of the container failed")
	ErrIPv4Addresses                 = NewError("getting IPv4 addresses of the container failed")
	ErrIPv6Addresses                 = NewError("getting IPv6 addresses of the container failed")
	ErrKMemLimit                     = NewError("your kernel does not support cgroup kernel memory controller")
	ErrLoadConfigFailed              = NewError("loading config file for the container failed")
	ErrMemLimit                      = NewError("your kernel does not support cgroup memory controller")
	ErrMemorySwapLimit               = NewError("your kernel does not support cgroup swap controller")
	ErrMethodNotAllowed              = NewError("the requested method is not currently supported with unprivileged containers")
	ErrNewFailed                     = NewError("allocating the container failed")
	ErrNoSnapshot                    = NewError("container has no snapshot")
	ErrNotDefined                    = NewError("container is not defined")
	ErrNotFrozen                     = NewError("container is not frozen")
	ErrNotRunning                    = NewError("container is not running")
	ErrNotSupported                  = NewError("method is not supported by this LXC version")
	ErrRebootFailed                  = NewError("rebooting the container failed")
	ErrRemoveDeviceNodeFailed        = NewError("removing device from container failed")
	ErrRenameFailed                  = NewError("renaming the container failed")
	ErrRestoreFailed                 = NewError("restore failed")
	ErrRestoreSnapshotFailed         = NewError("restoring the container failed")
	ErrSaveConfigFailed              = NewError("saving config file for the container failed")
	ErrSettingCgroupItemFailed       = NewError("setting cgroup item for the container failed")
	ErrSettingConfigItemFailed       = NewError("setting config item for the container failed")
	ErrSettingConfigPathFailed       = NewError("setting config file for the container failed")
	ErrSettingKMemoryLimitFailed     = NewError("setting kernel memory limit for the container failed")
	ErrSettingMemoryLimitFailed      = NewError("setting memory limit for the container failed")
	ErrSettingMemorySwapLimitFailed  = NewError("setting memory+swap limit for the container failed")
	ErrSettingSoftMemoryLimitFailed  = NewError("setting soft memory limit for the container failed")
	ErrShutdownFailed                = NewError("shutting down the container failed")
	ErrSoftMemLimit                  = NewError("your kernel does not support cgroup memory controller")
	ErrStartFailed                   = NewError("starting the container failed")
	ErrStopFailed                    = NewError("stopping the container failed")
	ErrTemplateNotAllowed            = NewError("unprivileged users only allowed to use \"download\" template")
	ErrUnfreezeFailed                = NewError("unfreezing the container failed")
	ErrUnknownBackendStore           = NewError("unknown backend type")
)
View Source
var BusyboxTemplateOptions = TemplateOptions{
	Template: "busybox",
}

BusyboxTemplateOptions is a convenient set of options for "busybox" template.

View Source
var DefaultAttachOptions = AttachOptions{
	Namespaces: -1,
	Arch:       -1,
	Cwd:        "/",
	UID:        -1,
	GID:        -1,
	ClearEnv:   false,
	Env:        nil,
	EnvToKeep:  nil,
	StdinFd:    os.Stdin.Fd(),
	StdoutFd:   os.Stdout.Fd(),
	StderrFd:   os.Stderr.Fd(),
}

DefaultAttachOptions is a convenient set of options to be used.

View Source
var DefaultCloneOptions = CloneOptions{
	Backend: Directory,
}

DefaultCloneOptions is a convenient set of options to be used.

View Source
var DefaultConsoleOptions = ConsoleOptions{
	Tty:             -1,
	StdinFd:         os.Stdin.Fd(),
	StdoutFd:        os.Stdout.Fd(),
	StderrFd:        os.Stderr.Fd(),
	EscapeCharacter: 'a',
}

DefailtConsoleOptions is a convenient set of options to be used.

View Source
var DownloadTemplateOptions = TemplateOptions{
	Template: "download",
	Distro:   "ubuntu",
	Release:  "trusty",
	Arch:     "amd64",
}

DownloadTemplateOptions is a convenient set of options for "download" template.

View Source
var StateMap = map[string]State{
	"STOPPED":  STOPPED,
	"STARTING": STARTING,
	"RUNNING":  RUNNING,
	"STOPPING": STOPPING,
	"ABORTING": ABORTING,
	"FREEZING": FREEZING,
	"FROZEN":   FROZEN,
	"THAWED":   THAWED,
}

StateMap provides the mapping betweens the state names and states

View Source
var UbuntuTemplateOptions = TemplateOptions{
	Template: "ubuntu",
}

UbuntuTemplateOptions is a convenient set of options for "ubuntu" template.

Functions

func Acquire

func Acquire(c *Container) bool

Acquire increments the reference counter of the container object.

func ActiveContainerNames

func ActiveContainerNames(lxcpath ...string) []string

ActiveContainerNames returns the names of the active containers on the system.

func ContainerNames

func ContainerNames(lxcpath ...string) []string

ContainerNames returns the names of defined and active containers on the system.

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns default config path.

func DefaultLvmVg

func DefaultLvmVg() string

DefaultLvmVg returns the name of the default LVM volume group.

func DefaultZfsRoot

func DefaultZfsRoot() string

DefaultZfsRoot returns the name of the default ZFS root.

func DefinedContainerNames

func DefinedContainerNames(lxcpath ...string) []string

DefinedContainerNames returns the names of the defined containers on the system.

func GlobalConfigItem

func GlobalConfigItem(name string) string

GlobalConfigItem returns the value of the given global config key.

func NewError

func NewError(msg string) error

NewError creates a new error with the given msg argument.

func Release

func Release(c *Container) bool

Release decrements the reference counter of the container object.

func Version

func Version() string

Version returns the LXC version.

func VersionAtLeast

func VersionAtLeast(major int, minor int, micro int) bool

func VersionNumber

func VersionNumber() (major int, minor int)

Types

type AttachOptions

type AttachOptions struct {

	// Specify the namespaces to attach to, as OR'ed list of clone flags (syscall.CLONE_NEWNS | syscall.CLONE_NEWUTS ...).
	Namespaces int

	// Specify the architecture which the kernel should appear to be running as to the command executed.
	Arch Personality

	// Cwd specifies the working directory of the command.
	Cwd string

	// UID specifies the user id to run as.
	UID int

	// GID specifies the group id to run as.
	GID int

	// If ClearEnv is true the environment is cleared before running the command.
	ClearEnv bool

	// Env specifies the environment of the process.
	Env []string

	// EnvToKeep specifies the environment of the process when ClearEnv is true.
	EnvToKeep []string

	// StdinFd specifies the fd to read input from.
	StdinFd uintptr

	// StdoutFd specifies the fd to write output to.
	StdoutFd uintptr

	// StderrFd specifies the fd to write error output to.
	StderrFd uintptr
}

AttachOptions type is used for defining various attach options.

type BackendStore

type BackendStore int

BackendStore type specifies possible backend types.

const (
	// Btrfs backendstore type
	Btrfs BackendStore = iota + 1
	// Directory backendstore type
	Directory
	// LVM backendstore type
	LVM
	// ZFS backendstore type
	ZFS
	// Aufs backendstore type
	Aufs
	// Overlayfs backendstore type
	Overlayfs
	// Loopback backendstore type
	Loopback
	// Best backendstore type
	Best
)

func (*BackendStore) Set

func (t *BackendStore) Set(value string) error

Set is the method to set the flag value, part of the flag.Value interface.

func (BackendStore) String

func (t BackendStore) String() string

BackendStore as string

type ByteSize

type ByteSize float64

ByteSize type

const (

	// KB - kilobyte
	KB ByteSize = 1 << (10 * iota)
	// MB - megabyte
	MB
	// GB - gigabyte
	GB
	// TB - terabyte
	TB
	// PB - petabyte
	PB
	// EB - exabyte
	EB
	// ZB - zettabyte
	ZB
	// YB - yottabyte
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

type CheckpointOptions

type CheckpointOptions struct {
	Directory string
	Stop      bool
	Verbose   bool
}

CheckpointOptions type is used for defining checkpoint options for CRIU

type CloneOptions

type CloneOptions struct {

	// Backend specifies the type of the backend.
	Backend BackendStore

	// lxcpath in which to create the new container. If not set the original container's lxcpath will be used.
	ConfigPath string

	// Do not change the hostname of the container (in the root filesystem).
	KeepName bool

	// Use the same MAC address as the original container, rather than generating a new random one.
	KeepMAC bool

	// Create a snapshot rather than copy.
	Snapshot bool
}

CloneOptions type is used for defining various clone options.

type ConsoleOptions

type ConsoleOptions struct {

	// Tty number to attempt to allocate, -1 to allocate the first available tty, or 0 to allocate the console.
	Tty int

	// StdinFd specifies the fd to read input from.
	StdinFd uintptr

	// StdoutFd specifies the fd to write output to.
	StdoutFd uintptr

	// StderrFd specifies the fd to write error output to.
	StderrFd uintptr

	// EscapeCharacter (a means <Ctrl a>, b maens <Ctrl b>).
	EscapeCharacter rune
}

ConsoleOptions type is used for defining various console options.

type Container

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

Container struct

func ActiveContainers

func ActiveContainers(lxcpath ...string) []Container

ActiveContainers returns the active containers on the system. Only containers that could retrieved successfully are returned.

func Containers

func Containers(lxcpath ...string) []Container

Containers returns the defined and active containers on the system. Only containers that could retrieved successfully are returned.

func DefinedContainers

func DefinedContainers(lxcpath ...string) []Container

DefinedContainers returns the defined containers on the system. Only containers that could retrieved successfully are returned.

func NewContainer

func NewContainer(name string, lxcpath ...string) (*Container, error)

NewContainer returns a new container struct.

func (*Container) AddDeviceNode

func (c *Container) AddDeviceNode(source string, destination ...string) error

AddDeviceNode adds specified device to the container.

func (*Container) AttachInterface

func (c *Container) AttachInterface(source, destination string) error

AttachInterface attaches specifed netdev to the container.

func (*Container) AttachShell

func (c *Container) AttachShell(options AttachOptions) error

AttachShell attaches a shell to the container. It clears all environment variables before attaching.

func (*Container) BlkioUsage

func (c *Container) BlkioUsage() (ByteSize, error)

BlkioUsage returns number of bytes transferred to/from the disk by the container.

func (*Container) CPUStats

func (c *Container) CPUStats() (map[string]int64, error)

CPUStats returns the number of CPU cycles (in the units defined by USER_HZ on the system) consumed by tasks in this cgroup and its children in both user mode and system (kernel) mode.

func (*Container) CPUTime

func (c *Container) CPUTime() (time.Duration, error)

CPUTime returns the total CPU time (in nanoseconds) consumed by all tasks in this cgroup (including tasks lower in the hierarchy).

func (*Container) CPUTimePerCPU

func (c *Container) CPUTimePerCPU() (map[int]time.Duration, error)

CPUTimePerCPU returns the CPU time (in nanoseconds) consumed on each CPU by all tasks in this cgroup (including tasks lower in the hierarchy).

func (*Container) CgroupItem

func (c *Container) CgroupItem(key string) []string

CgroupItem returns the value of the given cgroup subsystem value.

func (*Container) Checkpoint

func (c *Container) Checkpoint(opts CheckpointOptions) error

Checkpoint checkpoints the container.

func (*Container) ClearConfig

func (c *Container) ClearConfig()

ClearConfig completely clears the containers in-memory configuration.

func (*Container) ClearConfigItem

func (c *Container) ClearConfigItem(key string) error

ClearConfigItem clears the value of given config item.

func (*Container) Clone

func (c *Container) Clone(name string, options CloneOptions) error

Clone clones the container using given arguments with specified backend.

func (*Container) ConfigFileName

func (c *Container) ConfigFileName() string

ConfigFileName returns the container's configuration file's name.

func (*Container) ConfigItem

func (c *Container) ConfigItem(key string) []string

ConfigItem returns the value of the given config item.

func (*Container) ConfigKeys

func (c *Container) ConfigKeys(key ...string) []string

ConfigKeys returns the names of the config items.

func (*Container) ConfigPath

func (c *Container) ConfigPath() string

ConfigPath returns the configuration file's path.

func (*Container) Console

func (c *Container) Console(options ConsoleOptions) error

Console allocates and runs a console tty from container

This function will not return until the console has been exited by the user.

func (*Container) ConsoleFd

func (c *Container) ConsoleFd(ttynum int) (int, error)

ConsoleFd allocates a console tty from container ttynum: tty number to attempt to allocate or -1 to allocate the first available tty

Returns "ttyfd" on success, -1 on failure. The returned "ttyfd" is used to keep the tty allocated. The caller should close "ttyfd" to indicate that it is done with the allocated console so that it can be allocated by another caller.

func (*Container) Controllable

func (c *Container) Controllable() bool

Controllable returns true if the caller can control the container.

func (*Container) Create

func (c *Container) Create(options TemplateOptions) error

Create creates the container using given TemplateOptions

func (*Container) CreateSnapshot

func (c *Container) CreateSnapshot() (*Snapshot, error)

CreateSnapshot creates a new snapshot.

func (*Container) Daemonize

func (c *Container) Daemonize() bool

Daemonize returns true if the container wished to be daemonized.

func (*Container) Defined

func (c *Container) Defined() bool

Defined returns true if the container is already defined.

func (*Container) Destroy

func (c *Container) Destroy() error

Destroy destroys the container.

func (*Container) DestroyAllSnapshots

func (c *Container) DestroyAllSnapshots() error

DestroyAllSnapshots destroys all the snapshot.

func (*Container) DestroySnapshot

func (c *Container) DestroySnapshot(snapshot Snapshot) error

DestroySnapshot destroys the specified snapshot.

func (*Container) DestroyWithAllSnapshots

func (c *Container) DestroyWithAllSnapshots() error

DestroyWithAllSnapshots destroys the container and its snapshots

func (*Container) DetachInterface

func (c *Container) DetachInterface(source string) error

DetachInterface detaches specifed netdev from the container.

func (*Container) DetachInterfaceRename

func (c *Container) DetachInterfaceRename(source, target string) error

DetachInterfaceRename detaches specifed netdev from the container and renames it.

func (*Container) Execute

func (c *Container) Execute(args ...string) ([]byte, error)

Execute executes the given command in a temporary container.

func (*Container) Freeze

func (c *Container) Freeze() error

Freeze freezes the running container.

func (*Container) IPAddress

func (c *Container) IPAddress(interfaceName string) ([]string, error)

IPAddress returns the IP address of the given network interface.

func (*Container) IPAddresses

func (c *Container) IPAddresses() ([]string, error)

IPAddresses returns all IP addresses.

func (*Container) IPv4Address

func (c *Container) IPv4Address(interfaceName string) ([]string, error)

IPv4Address returns the IPv4 address of the given network interface.

func (*Container) IPv4Addresses

func (c *Container) IPv4Addresses() ([]string, error)

IPv4Addresses returns all IPv4 addresses.

func (*Container) IPv6Address

func (c *Container) IPv6Address(interfaceName string) ([]string, error)

IPv6Address returns the IPv6 address of the given network interface.

func (*Container) IPv6Addresses

func (c *Container) IPv6Addresses() ([]string, error)

IPv6Addresses returns all IPv6 addresses.

func (*Container) InitPid

func (c *Container) InitPid() int

InitPid returns the process ID of the container's init process seen from outside the container.

func (*Container) InterfaceStats

func (c *Container) InterfaceStats() (map[string]map[string]ByteSize, error)

InterfaceStats returns the stats about container's network interfaces

func (*Container) Interfaces

func (c *Container) Interfaces() ([]string, error)

Interfaces returns the names of the network interfaces.

func (*Container) KernelMemoryLimit

func (c *Container) KernelMemoryLimit() (ByteSize, error)

KernelMemoryLimit returns kernel memory limit of the container in bytes.

func (*Container) KernelMemoryUsage

func (c *Container) KernelMemoryUsage() (ByteSize, error)

KernelMemoryUsage returns current kernel memory allocation of the container in bytes.

func (*Container) LoadConfigFile

func (c *Container) LoadConfigFile(path string) error

LoadConfigFile loads the configuration file from given path.

func (*Container) LogFile

func (c *Container) LogFile() string

LogFile returns the name of the logfile.

func (*Container) LogLevel

func (c *Container) LogLevel() LogLevel

LogLevel returns the level of the logfile.

func (*Container) MemoryLimit

func (c *Container) MemoryLimit() (ByteSize, error)

MemoryLimit returns memory limit of the container in bytes.

func (*Container) MemorySwapLimit

func (c *Container) MemorySwapLimit() (ByteSize, error)

MemorySwapLimit returns the memory+swap limit of the container in bytes.

func (*Container) MemorySwapUsage

func (c *Container) MemorySwapUsage() (ByteSize, error)

MemorySwapUsage returns memory+swap usage of the container in bytes.

func (*Container) MemoryUsage

func (c *Container) MemoryUsage() (ByteSize, error)

MemoryUsage returns memory usage of the container in bytes.

func (*Container) Migrate

func (c *Container) Migrate(cmd uint, opts MigrateOptions) error

func (*Container) Name

func (c *Container) Name() string

Name returns the name of the container.

func (*Container) Reboot

func (c *Container) Reboot() error

Reboot reboots the container.

func (*Container) RemoveDeviceNode

func (c *Container) RemoveDeviceNode(source string, destination ...string) error

RemoveDeviceNode removes the specified device from the container.

func (*Container) Rename

func (c *Container) Rename(name string) error

Rename renames the container.

func (*Container) Restore

func (c *Container) Restore(opts RestoreOptions) error

Restore restores the container from a checkpoint.

func (*Container) RestoreSnapshot

func (c *Container) RestoreSnapshot(snapshot Snapshot, name string) error

RestoreSnapshot creates a new container based on a snapshot.

func (*Container) RunCommand

func (c *Container) RunCommand(args []string, options AttachOptions) (bool, error)

RunCommand attachs a shell and runs the command within the container. The process will wait for the command to finish and return a success status. An error is returned only when invocation of the command completely fails.

func (*Container) RunCommandStatus

func (c *Container) RunCommandStatus(args []string, options AttachOptions) (int, error)

RunCommandStatus attachs a shell and runs the command within the container. The process will wait for the command to finish and return the result of waitpid(), i.e. the process' exit status. An error is returned only when invocation of the command completely fails.

func (*Container) Running

func (c *Container) Running() bool

Running returns true if the container is already running.

func (*Container) RunningConfigItem

func (c *Container) RunningConfigItem(key string) []string

RunningConfigItem returns the value of the given config item.

func (*Container) SaveConfigFile

func (c *Container) SaveConfigFile(path string) error

SaveConfigFile saves the configuration file to given path.

func (*Container) SetCgroupItem

func (c *Container) SetCgroupItem(key string, value string) error

SetCgroupItem sets the value of given cgroup subsystem value.

func (*Container) SetConfigItem

func (c *Container) SetConfigItem(key string, value string) error

SetConfigItem sets the value of the given config item.

func (*Container) SetConfigPath

func (c *Container) SetConfigPath(path string) error

SetConfigPath sets the configuration file's path.

func (*Container) SetKernelMemoryLimit

func (c *Container) SetKernelMemoryLimit(limit ByteSize) error

SetKernelMemoryLimit sets kernel memory limit of the container in bytes.

func (*Container) SetLogFile

func (c *Container) SetLogFile(filename string) error

SetLogFile sets the name of the logfile.

func (*Container) SetLogLevel

func (c *Container) SetLogLevel(level LogLevel) error

SetLogLevel sets the level of the logfile.

func (*Container) SetMemoryLimit

func (c *Container) SetMemoryLimit(limit ByteSize) error

SetMemoryLimit sets memory limit of the container in bytes.

func (*Container) SetMemorySwapLimit

func (c *Container) SetMemorySwapLimit(limit ByteSize) error

SetMemorySwapLimit sets memory+swap limit of the container in bytes.

func (*Container) SetSoftMemoryLimit

func (c *Container) SetSoftMemoryLimit(limit ByteSize) error

SetSoftMemoryLimit sets soft memory limit of the container in bytes.

func (*Container) SetVerbosity

func (c *Container) SetVerbosity(verbosity Verbosity)

SetVerbosity sets the verbosity level of some API calls

func (*Container) Shutdown

func (c *Container) Shutdown(timeout time.Duration) error

Shutdown shuts down the container.

func (*Container) Snapshots

func (c *Container) Snapshots() ([]Snapshot, error)

Snapshots returns the list of container snapshots.

func (*Container) SoftMemoryLimit

func (c *Container) SoftMemoryLimit() (ByteSize, error)

SoftMemoryLimit returns soft memory limit of the container in bytes.

func (*Container) Start

func (c *Container) Start() error

Start starts the container.

func (*Container) State

func (c *Container) State() State

State returns the state of the container.

func (*Container) Stop

func (c *Container) Stop() error

Stop stops the container.

func (*Container) Unfreeze

func (c *Container) Unfreeze() error

Unfreeze thaws the frozen container.

func (*Container) Wait

func (c *Container) Wait(state State, timeout time.Duration) bool

Wait waits for container to reach a particular state.

func (*Container) WaitIPAddresses

func (c *Container) WaitIPAddresses(timeout time.Duration) ([]string, error)

WaitIPAddresses waits until IPAddresses call returns something or time outs

func (*Container) WantCloseAllFds

func (c *Container) WantCloseAllFds(state bool) error

WantCloseAllFds determines whether container wishes all file descriptors to be closed on startup.

func (*Container) WantDaemonize

func (c *Container) WantDaemonize(state bool) error

WantDaemonize determines if the container wants to run daemonized.

type Error

type Error struct {
	Message string
}

Error represents a basic error that implies the error interface.

func (*Error) Error

func (e *Error) Error() string

type LogLevel

type LogLevel int

LogLevel type specifies possible log levels.

const (
	// TRACE priority
	TRACE LogLevel = iota
	// DEBUG priority
	DEBUG
	// INFO priority
	INFO
	// NOTICE priority
	NOTICE
	// WARN priority
	WARN
	// ERROR priority
	ERROR
	// CRIT priority
	CRIT
	// ALERT priority
	ALERT
	// FATAL priority
	FATAL
)

func (LogLevel) String

func (l LogLevel) String() string

type MigrateOptions

type MigrateOptions struct {
	Directory  string
	Verbose    bool
	Stop       bool
	PredumpDir string
}

type Personality

type Personality int64

Personality allows to set the architecture for the container.

const (
	X86    Personality = 0x0008
	X86_64             = 0x0000
)

type RestoreOptions

type RestoreOptions struct {
	Directory string
	Verbose   bool
}

RestoreOptions type is used for defining restore options for CRIU

type Snapshot

type Snapshot struct {
	Name        string
	CommentPath string
	Timestamp   string
	Path        string
}

Snapshot struct

type State

type State int

State type specifies possible container states.

const (
	// STOPPED means container is not running
	STOPPED State = iota + 1
	// STARTING means container is starting
	STARTING
	// RUNNING means container is running
	RUNNING
	// STOPPING means container is stopping
	STOPPING
	// ABORTING means container is aborting
	ABORTING
	// FREEZING means container is freezing
	FREEZING
	// FROZEN means containe is frozen
	FROZEN
	// THAWED means container is thawed
	THAWED
)

func (State) String

func (t State) String() string

State as string

type TemplateOptions

type TemplateOptions struct {

	// Template specifies the name of the template.
	Template string

	// Backend specifies the type of the backend.
	Backend BackendStore

	// Distro specifies the name of the distribution.
	Distro string

	// Release specifies the name/version of the distribution.
	Release string

	// Arch specified the architecture of the container.
	Arch string

	// Variant specifies the variant of the image (default: "default").
	Variant string

	// Image server (default: "images.linuxcontainers.org").
	Server string

	// GPG keyid (default: 0x...).
	KeyID string

	// GPG keyserver to use.
	KeyServer string

	// Disable GPG validation (not recommended).
	DisableGPGValidation bool

	// Flush the local copy (if present).
	FlushCache bool

	// Force the use of the local copy even if expired.
	ForceCache bool

	// ExtraArgs provides a way to specify template specific args.
	ExtraArgs []string
}

TemplateOptions type is used for defining various template options.

type Verbosity

type Verbosity int

Verbosity type

const (
	// Quiet makes some API calls not to write anything to stdout
	Quiet Verbosity = 1 << iota
	// Verbose makes some API calls write to stdout
	Verbose
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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