Documentation ¶
Index ¶
- Constants
- Variables
- func CopyStringStringMap(m map[string]string) map[string]string
- func FilterImages(images []inspect.ImageResult, filters []ImageResultFilter) []inspect.ImageResult
- func FuncTimer(funcName string)
- func GetInsecureRegistries() ([]string, error)
- func GetPolicyContext(path string) (*signature.PolicyContext, error)
- func GetRegistries() ([]string, error)
- func MatchesID(id, argID string) bool
- func MatchesReference(name, argName string) bool
- func MountExists(specMounts []spec.Mount, dest string) bool
- func ParseImageNames(names []string) (tags, digests []string, err error)
- func RemoveScientificNotationFromFloat(x float64) (float64, error)
- func StringInSlice(s string, sl []string) bool
- func WriteFile(content string, path string) error
- type BoltState
- func (s *BoltState) AddContainer(ctr *Container) error
- func (s *BoltState) AddContainerToPod(pod *Pod, ctr *Container) error
- func (s *BoltState) AddPod(pod *Pod) error
- func (s *BoltState) AllContainers() ([]*Container, error)
- func (s *BoltState) AllPods() ([]*Pod, error)
- func (s *BoltState) Close() error
- func (s *BoltState) Container(id string) (*Container, error)
- func (s *BoltState) ContainerInUse(ctr *Container) ([]string, error)
- func (s *BoltState) HasContainer(id string) (bool, error)
- func (s *BoltState) HasPod(id string) (bool, error)
- func (s *BoltState) LookupContainer(idOrName string) (*Container, error)
- func (s *BoltState) LookupPod(idOrName string) (*Pod, error)
- func (s *BoltState) Pod(id string) (*Pod, error)
- func (s *BoltState) PodContainers(pod *Pod) ([]*Container, error)
- func (s *BoltState) PodContainersByID(pod *Pod) ([]string, error)
- func (s *BoltState) PodHasContainer(pod *Pod, id string) (bool, error)
- func (s *BoltState) Refresh() error
- func (s *BoltState) RemoveContainer(ctr *Container) error
- func (s *BoltState) RemoveContainerFromPod(pod *Pod, ctr *Container) error
- func (s *BoltState) RemovePod(pod *Pod) error
- func (s *BoltState) RemovePodContainers(pod *Pod) error
- func (s *BoltState) SaveContainer(ctr *Container) error
- func (s *BoltState) UpdateContainer(ctr *Container) error
- type Container
- func (c *Container) AddArtifact(name string, data []byte) error
- func (c *Container) Attach(noStdin bool, keys string, attached chan<- bool) error
- func (c *Container) Batch(batchFunc func(*Container) error) error
- func (c *Container) CGroupPath() cgroups.Path
- func (c *Container) CgroupParent() string
- func (c *Container) Cleanup() error
- func (c *Container) Commit(pause bool, options CopyOptions) error
- func (c *Container) Config() *ContainerConfig
- func (c *Container) CreatedTime() time.Time
- func (c *Container) DNSOption() []string
- func (c *Container) DNSSearch() []string
- func (c *Container) DNSServers() []net.IP
- func (c *Container) Dependencies() []string
- func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) error
- func (c *Container) ExitCode() (int32, error)
- func (c *Container) Export(path string) error
- func (c *Container) FinishedTime() (time.Time, error)
- func (c *Container) GetArtifact(name string) ([]byte, error)
- func (c *Container) GetContainerPidInformation(args []string) ([]string, error)
- func (c *Container) GetContainerPids() ([]string, error)
- func (c *Container) GetContainerStats(previousStats *ContainerStats) (*ContainerStats, error)
- func (c *Container) Hostname() string
- func (c *Container) HostsAdd() []string
- func (c *Container) ID() string
- func (c *Container) IPAddress() (net.IP, error)
- func (c *Container) Image() (string, string)
- func (c *Container) ImageVolumes() bool
- func (c *Container) Init() (err error)
- func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error)
- func (c *Container) Kill(signal uint) error
- func (c *Container) Labels() map[string]string
- func (c *Container) LogPath() string
- func (c *Container) Mount(label string) (string, error)
- func (c *Container) MountLabel() string
- func (c *Container) Mounted() (bool, error)
- func (c *Container) Mountpoint() (string, error)
- func (c *Container) Name() string
- func (c *Container) NamespacePath(ns LinuxNS) (string, error)
- func (c *Container) NewNetNS() bool
- func (c *Container) OOMKilled() (bool, error)
- func (c *Container) PID() (int, error)
- func (c *Container) Pause() error
- func (c *Container) PodID() string
- func (c *Container) PortMappings() []ocicni.PortMapping
- func (c *Container) Privileged() bool
- func (c *Container) ProcessLabel() string
- func (c *Container) RWSize() (int64, error)
- func (c *Container) RemoveArtifact(name string) error
- func (c *Container) RootFsSize() (int64, error)
- func (c *Container) RuntimeName() string
- func (c *Container) ShmDir() string
- func (c *Container) ShmSize() int64
- func (c *Container) Spec() *spec.Spec
- func (c *Container) Start() error
- func (c *Container) StartedTime() (time.Time, error)
- func (c *Container) State() (ContainerStatus, error)
- func (c *Container) StaticDir() string
- func (c *Container) Stdin() bool
- func (c *Container) Stop() error
- func (c *Container) StopSignal() uint
- func (c *Container) StopTimeout() uint
- func (c *Container) StopWithTimeout(timeout uint) error
- func (c *Container) Sync() error
- func (c *Container) Unmount() error
- func (c *Container) Unpause() error
- func (c *Container) User() string
- func (c *Container) Wait() (int32, error)
- func (c *Container) WriteStringToRundir(destFile, output string) (string, error)
- type ContainerConfig
- type ContainerFilter
- type ContainerInfo
- type ContainerStats
- type ContainerStatus
- type CopyOptions
- type CtrCreateOption
- func WithCgroupNSFrom(nsCtr *Container) CtrCreateOption
- func WithCgroupParent(parent string) CtrCreateOption
- func WithDNS(dnsServers []string) CtrCreateOption
- func WithDNSOption(dnsOptions []string) CtrCreateOption
- func WithDNSSearch(searchDomains []string) CtrCreateOption
- func WithHosts(hosts []string) CtrCreateOption
- func WithIPCNSFrom(nsCtr *Container) CtrCreateOption
- func WithLabels(labels map[string]string) CtrCreateOption
- func WithLogPath(path string) CtrCreateOption
- func WithMountNSFrom(nsCtr *Container) CtrCreateOption
- func WithName(name string) CtrCreateOption
- func WithNetNS(portMappings []ocicni.PortMapping) CtrCreateOption
- func WithNetNSFrom(nsCtr *Container) CtrCreateOption
- func WithPIDNSFrom(nsCtr *Container) CtrCreateOption
- func WithPrivileged(privileged bool) CtrCreateOption
- func WithRootFSFromImage(imageID string, imageName string, useImageVolumes bool) CtrCreateOption
- func WithSELinuxLabels(processLabel, mountLabel string) CtrCreateOption
- func WithShmDir(dir string) CtrCreateOption
- func WithShmSize(size int64) CtrCreateOption
- func WithStdin() CtrCreateOption
- func WithStopSignal(signal syscall.Signal) CtrCreateOption
- func WithStopTimeout(timeout uint) CtrCreateOption
- func WithUTSNSFrom(nsCtr *Container) CtrCreateOption
- func WithUser(user string) CtrCreateOption
- func WithUserNSFrom(nsCtr *Container) CtrCreateOption
- type Image
- func (k *Image) Decompose() error
- func (k *Image) GetFQName() (string, error)
- func (k *Image) GetImageID() (string, error)
- func (k *Image) GetLocalImageName() (string, string, error)
- func (k *Image) GetManifest() error
- func (k *Image) GetNameByID() (string, error)
- func (k *Image) HasLatest() (bool, error)
- func (k *Image) Pull(writer io.Writer) error
- func (k *Image) Remove(force bool) (string, error)
- type ImageFilter
- type ImageFilterParams
- type ImageResultFilter
- type InMemoryState
- func (s *InMemoryState) AddContainer(ctr *Container) error
- func (s *InMemoryState) AddContainerToPod(pod *Pod, ctr *Container) error
- func (s *InMemoryState) AddPod(pod *Pod) error
- func (s *InMemoryState) AllContainers() ([]*Container, error)
- func (s *InMemoryState) AllPods() ([]*Pod, error)
- func (s *InMemoryState) Close() error
- func (s *InMemoryState) Container(id string) (*Container, error)
- func (s *InMemoryState) ContainerInUse(ctr *Container) ([]string, error)
- func (s *InMemoryState) HasContainer(id string) (bool, error)
- func (s *InMemoryState) HasPod(id string) (bool, error)
- func (s *InMemoryState) LookupContainer(idOrName string) (*Container, error)
- func (s *InMemoryState) LookupPod(idOrName string) (*Pod, error)
- func (s *InMemoryState) Pod(id string) (*Pod, error)
- func (s *InMemoryState) PodContainers(pod *Pod) ([]*Container, error)
- func (s *InMemoryState) PodContainersByID(pod *Pod) ([]string, error)
- func (s *InMemoryState) PodHasContainer(pod *Pod, ctrID string) (bool, error)
- func (s *InMemoryState) Refresh() error
- func (s *InMemoryState) RemoveContainer(ctr *Container) error
- func (s *InMemoryState) RemoveContainerFromPod(pod *Pod, ctr *Container) error
- func (s *InMemoryState) RemovePod(pod *Pod) error
- func (s *InMemoryState) RemovePodContainers(pod *Pod) error
- func (s *InMemoryState) SaveContainer(ctr *Container) error
- func (s *InMemoryState) UpdateContainer(ctr *Container) error
- type InfoData
- type LinuxNS
- type OCIRuntime
- type Pod
- func (p *Pod) AllContainers() ([]*Container, error)
- func (p *Pod) AllContainersByID() ([]string, error)
- func (p *Pod) HasContainer(id string) (bool, error)
- func (p *Pod) ID() string
- func (p *Pod) Init() error
- func (p *Pod) Kill(signal uint) (map[string]error, error)
- func (p *Pod) Labels() map[string]string
- func (p *Pod) Name() string
- func (p *Pod) Start() (map[string]error, error)
- func (p *Pod) Status() (map[string]ContainerStatus, error)
- func (p *Pod) Stop() (map[string]error, error)
- type PodConfig
- type PodCreateOption
- type PodFilter
- type Runtime
- func (r *Runtime) GetAllContainers() ([]*Container, error)
- func (r *Runtime) GetConfig() *RuntimeConfig
- func (r *Runtime) GetContainer(id string) (*Container, error)
- func (r *Runtime) GetContainers(filters ...ContainerFilter) ([]*Container, error)
- func (r *Runtime) GetContainersByList(containers []string) ([]*Container, error)
- func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error)
- func (r *Runtime) GetHistory(image string) ([]ociv1.History, []types.BlobInfo, string, error)
- func (r *Runtime) GetImage(image string) (*storage.Image, error)
- func (r *Runtime) GetImageInspectInfo(image storage.Image) (*inspect.ImageData, error)
- func (r *Runtime) GetImageRef(image string) (types.Image, error)
- func (r *Runtime) GetImageResults() ([]inspect.ImageResult, error)
- func (r *Runtime) GetImages(params *ImageFilterParams, filters ...ImageFilter) ([]*storage.Image, error)
- func (r *Runtime) GetLatestContainer() (*Container, error)
- func (r *Runtime) GetPod(id string) (*Pod, error)
- func (r *Runtime) GetRunningContainers() ([]*Container, error)
- func (r *Runtime) HasContainer(id string) (bool, error)
- func (r *Runtime) HasPod(id string) (bool, error)
- func (r *Runtime) ImportImage(path string, options CopyOptions) error
- func (r *Runtime) Info() ([]InfoData, error)
- func (r *Runtime) IsImageID(input string) (bool, error)
- func (r *Runtime) LookupContainer(idOrName string) (*Container, error)
- func (r *Runtime) LookupPod(idOrName string) (*Pod, error)
- func (r *Runtime) NewContainer(rSpec *spec.Spec, options ...CtrCreateOption) (c *Container, err error)
- func (r *Runtime) NewImage(name string) Image
- func (r *Runtime) NewPod(options ...PodCreateOption) (*Pod, error)
- func (r *Runtime) ParseImageFilter(imageInput, filter string) (*ImageFilterParams, error)
- func (r *Runtime) Pods(filters ...PodFilter) ([]*Pod, error)
- func (r *Runtime) PullImage(imgName string, options CopyOptions) (string, error)
- func (r *Runtime) PushImage(source string, destination string, options CopyOptions) error
- func (r *Runtime) RemoveContainer(c *Container, force bool) error
- func (r *Runtime) RemoveImage(image *storage.Image, force bool) (string, error)
- func (r *Runtime) RemovePod(p *Pod, removeCtrs, force bool) error
- func (r *Runtime) Shutdown(force bool) error
- func (r *Runtime) TagImage(image *storage.Image, tag string) error
- func (r *Runtime) UntagImage(image *storage.Image, tag string) (string, error)
- func (r *Runtime) WithPod(pod *Pod) CtrCreateOption
- type RuntimeConfig
- type RuntimeContainerMetadata
- type RuntimeOption
- func WithCNIConfigDir(dir string) RuntimeOption
- func WithCNIPluginDir(dir string) RuntimeOption
- func WithCgroupManager(manager string) RuntimeOption
- func WithConmonEnv(environment []string) RuntimeOption
- func WithConmonPath(path string) RuntimeOption
- func WithDefaultTransport(defaultTransport string) RuntimeOption
- func WithMaxLogSize(limit int64) RuntimeOption
- func WithNoPivotRoot(noPivot bool) RuntimeOption
- func WithOCIRuntime(runtimePath string) RuntimeOption
- func WithSignaturePolicy(path string) RuntimeOption
- func WithStateType(storeType RuntimeStateStore) RuntimeOption
- func WithStaticDir(dir string) RuntimeOption
- func WithStorageConfig(config storage.StoreOptions) RuntimeOption
- func WithTmpDir(dir string) RuntimeOption
- type RuntimeStateStore
- type SQLState
- func (s *SQLState) AddContainer(ctr *Container) (err error)
- func (s *SQLState) AddContainerToPod(pod *Pod, ctr *Container) error
- func (s *SQLState) AddPod(pod *Pod) (err error)
- func (s *SQLState) AllContainers() ([]*Container, error)
- func (s *SQLState) AllPods() ([]*Pod, error)
- func (s *SQLState) Close() error
- func (s *SQLState) Container(id string) (*Container, error)
- func (s *SQLState) ContainerInUse(ctr *Container) ([]string, error)
- func (s *SQLState) HasContainer(id string) (bool, error)
- func (s *SQLState) HasPod(id string) (bool, error)
- func (s *SQLState) LookupContainer(idOrName string) (*Container, error)
- func (s *SQLState) LookupPod(idOrName string) (*Pod, error)
- func (s *SQLState) Pod(id string) (*Pod, error)
- func (s *SQLState) PodContainers(pod *Pod) ([]*Container, error)
- func (s *SQLState) PodContainersByID(pod *Pod) ([]string, error)
- func (s *SQLState) PodHasContainer(pod *Pod, ctrID string) (bool, error)
- func (s *SQLState) Refresh() (err error)
- func (s *SQLState) RemoveContainer(ctr *Container) error
- func (s *SQLState) RemoveContainerFromPod(pod *Pod, ctr *Container) error
- func (s *SQLState) RemovePod(pod *Pod) (err error)
- func (s *SQLState) RemovePodContainers(pod *Pod) (err error)
- func (s *SQLState) SaveContainer(ctr *Container) (err error)
- func (s *SQLState) UpdateContainer(ctr *Container) error
- type State
Constants ¶
const ( AttachPipeStdin = 1 AttachPipeStdout = 2 AttachPipeStderr = 3 )
Sync with stdpipe_t in conmon.c
const ( // CgroupfsCgroupsManager represents cgroupfs native cgroup manager CgroupfsCgroupsManager = "cgroupfs" // SystemdCgroupsManager represents systemd native cgroup manager SystemdCgroupsManager = "systemd" // ContainerCreateTimeout represents the value of container creating timeout ContainerCreateTimeout = 240 * time.Second // DefaultShmSize is the default shm size DefaultShmSize = 64 * 1024 * 1024 // NsRunDir is the default directory in which running network namespaces // are stored NsRunDir = "/var/run/netns" )
const CtrRemoveTimeout = 10
CtrRemoveTimeout is the default number of seconds to wait after stopping a container before sending the kill signal
const DBSchema = 11
DBSchema is the current DB schema version Increments every time a change is made to the database's tables
const ( // DefaultTransport is a prefix that we apply to an image name // to check docker hub first for the image DefaultTransport = "docker://" )
Runtime API constants
const (
// ExistsQuery is a query to check if a pod exists
ExistsQuery = "SELECT 1 FROM pods WHERE Id=?;"
)
Variables ¶
var ( // ErrNoSuchCtr indicates the requested container does not exist ErrNoSuchCtr = errors.New("no such container") // ErrNoSuchPod indicates the requested pod does not exist ErrNoSuchPod = errors.New("no such pod") // ErrNoSuchImage indicates the requested image does not exist ErrNoSuchImage = errors.New("no such image") // ErrCtrExists indicates a container with the same name or ID already // exists ErrCtrExists = errors.New("container already exists") // ErrPodExists indicates a pod with the same name or ID already exists ErrPodExists = errors.New("pod already exists") // ErrImageExists indicated an image with the same ID already exists ErrImageExists = errors.New("image already exists") // ErrCtrStateInvalid indicates a container is in an improper state for // the requested operation ErrCtrStateInvalid = errors.New("container state improper") // ErrRuntimeFinalized indicates that the runtime has already been // created and cannot be modified ErrRuntimeFinalized = errors.New("runtime has been finalized") // ErrCtrFinalized indicates that the container has already been created // and cannot be modified ErrCtrFinalized = errors.New("container has been finalized") // ErrPodFinalized indicates that the pod has already been created and // cannot be modified ErrPodFinalized = errors.New("pod has been finalized") // ErrInvalidArg indicates that an invalid argument was passed ErrInvalidArg = errors.New("invalid argument") // ErrEmptyID indicates that an empty ID was passed ErrEmptyID = errors.New("name or ID cannot be empty") // ErrInternal indicates an internal library error ErrInternal = errors.New("internal libpod error") // ErrRuntimeStopped indicates that the runtime has already been shut // down and no further operations can be performed on it ErrRuntimeStopped = errors.New("runtime has already been stopped") // ErrCtrStopped indicates that the requested container is not running // and the requested operation cannot be performed until it is started ErrCtrStopped = errors.New("container is stopped") // ErrCtrRemoved indicates that the container has already been removed // and no further operations can be performed on it ErrCtrRemoved = errors.New("container has already been removed") // ErrPodRemoved indicates that the pod has already been removed and no // further operations can be performed on it ErrPodRemoved = errors.New("pod has already been removed") // ErrDBClosed indicates that the connection to the state database has // already been closed ErrDBClosed = errors.New("database connection already closed") // ErrDBBadConfig indicates that the database has a different schema or // was created by a libpod with a different config ErrDBBadConfig = errors.New("database configuration mismatch") // ErrNotImplemented indicates that the requested functionality is not // yet present ErrNotImplemented = errors.New("not yet implemented") )
var ( // DockerArchive is the transport we prepend to an image name // when saving to docker-archive DockerArchive = dockerarchive.Transport.Name() // OCIArchive is the transport we prepend to an image name // when saving to oci-archive OCIArchive = ociarchive.Transport.Name() // DirTransport is the transport for pushing and pulling // images to and from a directory DirTransport = directory.Transport.Name() // TransportNames are the supported transports in string form TransportNames = [...]string{DefaultTransport, DockerArchive, OCIArchive, "ostree:", "dir:"} // TarballTransport is the transport for importing a tar archive // and creating a filesystem image TarballTransport = tarball.Transport.Name() // Docker is the transport for docker registries Docker = docker.Transport.Name() // Atomic is the transport for atomic registries Atomic = "atomic" )
var DefaultCgroupParent = "/libpod_parent"
DefaultCgroupParent is the default prefix to a cgroup path in libpod
Functions ¶
func CopyStringStringMap ¶
CopyStringStringMap deep copies a map[string]string and returns the result
func FilterImages ¶ added in v0.2.2
func FilterImages(images []inspect.ImageResult, filters []ImageResultFilter) []inspect.ImageResult
FilterImages filters images using a set of predefined fitler funcs
func FuncTimer ¶
func FuncTimer(funcName string)
FuncTimer helps measure the execution time of a function For debug purposes, do not leave in code used like defer FuncTimer("foo")
func GetInsecureRegistries ¶
GetInsecureRegistries obtains the list of inseure registries from the global registration file.
func GetPolicyContext ¶
func GetPolicyContext(path string) (*signature.PolicyContext, error)
GetPolicyContext creates a signature policy context for the given signature policy path
func GetRegistries ¶
GetRegistries gets the searchable registries from the global registration file.
func MatchesReference ¶
MatchesReference returns true if argName is a full or partial match for name Partial matches will register only if they match the most specific part of the name available For example, take the image docker.io/library/redis:latest redis, library/redis, docker.io/library/redis, redis:latest, etc. will match But redis:alpine, ry/redis, library, and io/library/redis will not
func MountExists ¶ added in v0.2.2
MountExists returns true if dest exists in the list of mounts
func ParseImageNames ¶
ParseImageNames parses the names we've stored with an image into a list of tagged references and a list of references which contain digests.
func RemoveScientificNotationFromFloat ¶
RemoveScientificNotationFromFloat returns a float without any scientific notation if the number has any. golang does not handle conversion of float64s that have scientific notation in them and otherwise stinks. please replace this if you have a better implementation.
func StringInSlice ¶
StringInSlice determines if a string is in a string slice, returns bool
Types ¶
type BoltState ¶
type BoltState struct {
// contains filtered or unexported fields
}
BoltState is a state implementation backed by a Bolt DB
func (*BoltState) AddContainer ¶
AddContainer adds a container to the state The container being added cannot belong to a pod
func (*BoltState) AddContainerToPod ¶
AddContainerToPod adds the given container to an existing pod The container will be added to the state and the pod
func (*BoltState) AllContainers ¶
AllContainers retrieves all the containers in the database
func (*BoltState) ContainerInUse ¶
ContainerInUse checks if other containers depend on the given container It returns a slice of the IDs of the containers depending on the given container. If the slice is empty, no containers depend on the given container
func (*BoltState) HasContainer ¶
HasContainer checks if a container is present in the state
func (*BoltState) LookupContainer ¶
LookupContainer retrieves a container from the state by full or unique partial ID or name
func (*BoltState) PodContainers ¶
PodContainers returns all the containers present in the given pod
func (*BoltState) PodContainersByID ¶
PodContainersByID returns the IDs of all containers present in the given pod
func (*BoltState) PodHasContainer ¶
PodHasContainer checks if the given pod has a container with the given ID
func (*BoltState) RemoveContainer ¶
RemoveContainer removes a container from the state Only removes containers not in pods - for containers that are a member of a pod, use RemoveContainerFromPod
func (*BoltState) RemoveContainerFromPod ¶
RemoveContainerFromPod removes a container from an existing pod The container will also be removed from the state
func (*BoltState) RemovePod ¶
RemovePod removes the given pod from the state Only empty pods can be removed
func (*BoltState) RemovePodContainers ¶
RemovePodContainers removes all containers in a pod
func (*BoltState) SaveContainer ¶
SaveContainer saves a container's current state in the database
func (*BoltState) UpdateContainer ¶
UpdateContainer updates a container's state from the database
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is a single OCI container ffjson: skip
func (*Container) AddArtifact ¶
AddArtifact creates and writes to an artifact file for the container
func (*Container) Attach ¶
Attach attaches to a container Returns fully qualified URL of streaming server for the container
func (*Container) Batch ¶
Batch starts a batch operation on the given container All commands in the passed function will execute under the same lock and without syncronyzing state after each operation This will result in substantial performance benefits when running numerous commands on the same container Note that the container passed into the Batch function cannot be removed during batched operations. runtime.RemoveContainer can only be called outside of Batch Any error returned by the given batch function will be returned unmodified by Batch As Batch normally disables updating the current state of the container, the Sync() function is provided to enable container state to be updated and checked within Batch.
func (*Container) CGroupPath ¶
CGroupPath returns a cgroups "path" for a given container.
func (*Container) CgroupParent ¶ added in v0.2.2
CgroupParent gets the container's CGroup parent
func (*Container) Cleanup ¶
Cleanup unmounts all mount points in container and cleans up container storage It also cleans up the network stack
func (*Container) Commit ¶
func (c *Container) Commit(pause bool, options CopyOptions) error
Commit commits the changes between a container and its image, creating a new image
func (*Container) Config ¶
func (c *Container) Config() *ContainerConfig
Config returns the configuration used to create the container
func (*Container) CreatedTime ¶ added in v0.2.2
CreatedTime gets the time when the container was created
func (*Container) DNSOption ¶ added in v0.2.2
DNSOption returns the DNS options that will be used in the container's resolv.conf If empty, options from the host's resolv.conf will be used instead
func (*Container) DNSSearch ¶ added in v0.2.2
DNSSearch returns the DNS search domains that will be used in the container's resolv.conf If empty, DNS Search domains from the host's resolv.conf will be used instead
func (*Container) DNSServers ¶ added in v0.2.2
DNSServers returns DNS servers that will be used in the container's resolv.conf If empty, DNS server from the host's resolv.conf will be used instead
func (*Container) Dependencies ¶
Dependencies gets the containers this container depends upon
func (*Container) Export ¶
Export exports a container's root filesystem as a tar archive The archive will be saved as a file at the given path
func (*Container) FinishedTime ¶
FinishedTime is the time the container was stopped
func (*Container) GetArtifact ¶
GetArtifact reads the specified artifact file from the container
func (*Container) GetContainerPidInformation ¶
GetContainerPidInformation calls ps with the appropriate options and returns the results as a string
func (*Container) GetContainerPids ¶
GetContainerPids reads sysfs to obtain the pids associated with the container's cgroup and uses locking
func (*Container) GetContainerStats ¶
func (c *Container) GetContainerStats(previousStats *ContainerStats) (*ContainerStats, error)
GetContainerStats gets the running stats for a given container
func (*Container) HostsAdd ¶ added in v0.2.2
HostsAdd returns hosts that will be added to the container's hosts file The host system's hosts file is used as a base, and these are appended to it
func (*Container) IPAddress ¶
IPAddress returns the IP address of the container If the container does not have a network namespace, an error will be returned
func (*Container) Image ¶ added in v0.2.2
Image returns the ID and name of the image used as the container's rootfs
func (*Container) ImageVolumes ¶ added in v0.2.2
ImageVolumes returns whether the container is configured to create persistent volumes requested by the image
func (*Container) Inspect ¶
func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error)
Inspect a container for low-level information
func (*Container) LogPath ¶
LogPath returns the path to the container's log file This file will only be present after Init() is called to create the container in runc
func (*Container) Mount ¶
Mount mounts a container's filesystem on the host The path where the container has been mounted is returned
func (*Container) MountLabel ¶ added in v0.2.2
MountLabel returns the SELinux mount label of the container
func (*Container) Mountpoint ¶
Mountpoint returns the path to the container's mounted storage as a string If the container is not mounted, no error is returned, but the mountpoint will be ""
func (*Container) NamespacePath ¶
NamespacePath returns the path of one of the container's namespaces If the container is not running, an error will be returned
func (*Container) NewNetNS ¶ added in v0.2.2
NewNetNS returns whether the container will create a new network namespace
func (*Container) OOMKilled ¶ added in v0.2.2
OOMKilled returns whether the container was killed by an OOM condition
func (*Container) PID ¶
PID returns the PID of the container An error is returned if the container is not running
func (*Container) PodID ¶
PodID returns the full ID of the pod the container belongs to, or "" if it does not belong to a pod
func (*Container) PortMappings ¶ added in v0.2.2
func (c *Container) PortMappings() []ocicni.PortMapping
PortMappings returns the ports that will be mapped into a container if a new network namespace is created If NewNetNS() is false, this value is unused
func (*Container) Privileged ¶ added in v0.2.2
Privileged returns whether the container is privileged
func (*Container) ProcessLabel ¶
ProcessLabel returns the selinux ProcessLabel of the container
func (*Container) RemoveArtifact ¶
RemoveArtifact deletes the specified artifacts file
func (*Container) RootFsSize ¶
RootFsSize returns the root FS size of the container
func (*Container) RuntimeName ¶
RuntimeName returns the name of the runtime
func (*Container) ShmSize ¶ added in v0.2.2
ShmSize returns the size of SHM device to be mounted into the container
func (*Container) Spec ¶
Spec returns the container's OCI runtime spec The spec returned is the one used to create the container. The running spec may differ slightly as mounts are added based on the image
func (*Container) StartedTime ¶
StartedTime is the time the container was started
func (*Container) State ¶
func (c *Container) State() (ContainerStatus, error)
State returns the current state of the container
func (*Container) StaticDir ¶ added in v0.2.2
StaticDir returns the directory used to store persistent container files
func (*Container) Stdin ¶ added in v0.2.2
Stdin returns whether STDIN on the container will be kept open
func (*Container) Stop ¶
Stop uses the container's stop signal (or SIGTERM if no signal was specified) to stop the container, and if it has not stopped after container's stop timeout, SIGKILL is used to attempt to forcibly stop the container Default stop timeout is 10 seconds, but can be overridden when the container is created
func (*Container) StopSignal ¶ added in v0.2.2
StopSignal is the signal that will be used to stop the container If it fails to stop the container, SIGKILL will be used after a timeout If StopSignal is 0, the default signal of SIGTERM will be used
func (*Container) StopTimeout ¶
StopTimeout returns the container's stop timeout If the container's default stop signal fails to kill the container, SIGKILL will be used after this timeout
func (*Container) StopWithTimeout ¶
StopWithTimeout is a version of Stop that allows a timeout to be specified manually. If timeout is 0, SIGKILL will be used immediately to kill the container.
func (*Container) Sync ¶
Sync updates the current state of the container, checking whether its state has changed Sync can only be used inside Batch() - otherwise, it will be done automatically. When called outside Batch(), Sync() is a no-op
type ContainerConfig ¶
type ContainerConfig struct { Spec *spec.Spec `json:"spec"` ID string `json:"id"` Name string `json:"name"` // Full ID of the pood the container belongs to Pod string `json:"pod,omitempty"` // Storage Config // Information on the image used for the root filesystem RootfsImageID string `json:"rootfsImageID,omitempty"` RootfsImageName string `json:"rootfsImageName,omitempty"` // Whether to mount volumes specified in the image ImageVolumes bool `json:"imageVolumes"` // Src path to be mounted on /dev/shm in container ShmDir string `json:"ShmDir,omitempty"` // Size of the container's SHM ShmSize int64 `json:"shmSize"` // Static directory for container content that will persist across // reboot StaticDir string `json:"staticDir"` // Mounts list contains all additional mounts into the container rootfs // These include the SHM mount // These must be unmounted before the container's rootfs is unmounted Mounts []string `json:"mounts,omitempty"` // Security Config // Whether the container is privileged Privileged bool `json:"privileged"` // SELinux process label for container ProcessLabel string `json:"ProcessLabel,omitempty"` // SELinux mount label for root filesystem MountLabel string `json:"MountLabel,omitempty"` // User and group to use in the container // Can be specified by name or UID/GID User string `json:"user,omitempty"` // Namespace Config // IDs of container to share namespaces with // NetNsCtr conflicts with the CreateNetNS bool IPCNsCtr string `json:"ipcNsCtr,omitempty"` MountNsCtr string `json:"mountNsCtr,omitempty"` NetNsCtr string `json:"netNsCtr,omitempty"` PIDNsCtr string `json:"pidNsCtr,omitempty"` UserNsCtr string `json:"userNsCtr,omitempty"` UTSNsCtr string `json:"utsNsCtr,omitempty"` CgroupNsCtr string `json:"cgroupNsCtr,omitempty"` // Network Config // CreateNetNS indicates that libpod should create and configure a new // network namespace for the container // This cannot be set if NetNsCtr is also set CreateNetNS bool `json:"createNetNS"` // PortMappings are the ports forwarded to the container's network // namespace // These are not used unless CreateNetNS is true PortMappings []ocicni.PortMapping `json:"portMappings,omitempty"` // DNS servers to use in container resolv.conf // Will override servers in host resolv if set DNSServer []net.IP `json:"dnsServer,omitempty"` // DNS Search domains to use in container resolv.conf // Will override search domains in host resolv if set DNSSearch []string `json:"dnsSearch,omitempty"` // DNS options to be set in container resolv.conf // With override options in host resolv if set DNSOption []string `json:"dnsOption,omitempty"` // Hosts to add in container // Will be appended to host's host file HostAdd []string `json:"hostsAdd,omitempty"` // Misc Options // Whether to keep container STDIN open Stdin bool `json:"stdin,omitempty"` // Labels is a set of key-value pairs providing additional information // about a container Labels map[string]string `json:"labels,omitempty"` // StopSignal is the signal that will be used to stop the container StopSignal uint `json:"stopSignal,omitempty"` // StopTimeout is the signal that will be used to stop the container StopTimeout uint `json:"stopTimeout,omitempty"` // Time container was created CreatedTime time.Time `json:"createdTime"` // Cgroup parent of the container CgroupParent string `json:"cgroupParent"` // LogPath log location LogPath string `json:"logPath"` }
ContainerConfig contains all information that was used to create the container. It may not be changed once created. It is stored, read-only, on disk
func (*ContainerConfig) MarshalJSON ¶
func (j *ContainerConfig) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*ContainerConfig) MarshalJSONBuf ¶
func (j *ContainerConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*ContainerConfig) UnmarshalJSON ¶
func (j *ContainerConfig) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*ContainerConfig) UnmarshalJSONFFLexer ¶
func (j *ContainerConfig) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type ContainerFilter ¶
ContainerFilter is a function to determine whether a container is included in command output. Containers to be outputted are tested using the function. A true return will include the container, a false return will exclude it.
type ContainerInfo ¶
ContainerInfo wraps a subset of information about a container: the locations of its nonvolatile and volatile per-container directories, along with a copy of the configuration blob from the image that was used to create the container, if the image had a configuration.
type ContainerStats ¶
type ContainerStats struct { ContainerID string Name string CPU float64 CPUNano uint64 SystemNano uint64 MemUsage uint64 MemLimit uint64 MemPerc float64 NetInput uint64 NetOutput uint64 BlockInput uint64 BlockOutput uint64 PIDs uint64 }
ContainerStats contains the statistics information for a running container
type ContainerStatus ¶
type ContainerStatus int
ContainerStatus represents the current state of a container
const ( // ContainerStateUnknown indicates that the container is in an error // state where information about it cannot be retrieved ContainerStateUnknown ContainerStatus = iota // ContainerStateConfigured indicates that the container has had its // storage configured but it has not been created in the OCI runtime ContainerStateConfigured ContainerStatus = iota // ContainerStateCreated indicates the container has been created in // the OCI runtime but not started ContainerStateCreated ContainerStatus = iota // ContainerStateRunning indicates the container is currently executing ContainerStateRunning ContainerStatus = iota // ContainerStateStopped indicates that the container was running but has // exited ContainerStateStopped ContainerStatus = iota // ContainerStatePaused indicates that the container has been paused ContainerStatePaused ContainerStatus = iota )
func (ContainerStatus) String ¶
func (t ContainerStatus) String() string
ContainerStatus returns a string representation for users of a container state
type CopyOptions ¶
type CopyOptions struct { // Compression specifies the type of compression which is applied to // layer blobs. The default is to not use compression, but // archive.Gzip is recommended. Compression archive.Compression // DockerRegistryOptions encapsulates settings that affect how we // connect or authenticate to a remote registry to which we want to // push the image. common.DockerRegistryOptions // SigningOptions encapsulates settings that control whether or not we // strip or add signatures to the image when pushing (uploading) the // image to a registry. common.SigningOptions // SigningPolicyPath this points to a alternative signature policy file, used mainly for testing SignaturePolicyPath string // AuthFile is the path of the cached credentials file defined by the user AuthFile string // Writer is the reportWriter for the output Writer io.Writer // Reference is the name for the image created when a tar archive is imported Reference string // ImageConfig is the Image spec for the image created when a tar archive is imported ImageConfig ociv1.Image // ManifestMIMEType is the manifest type of the image when saving to a directory ManifestMIMEType string // ForceCompress compresses the image layers when saving to a directory using the dir transport if true ForceCompress bool }
CopyOptions contains the options given when pushing or pulling images
type CtrCreateOption ¶
A CtrCreateOption is a functional option which alters the Container created by NewContainer
func WithCgroupNSFrom ¶
func WithCgroupNSFrom(nsCtr *Container) CtrCreateOption
WithCgroupNSFrom indicates the the container should join the CGroup namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
func WithCgroupParent ¶
func WithCgroupParent(parent string) CtrCreateOption
WithCgroupParent sets the Cgroup Parent of the new container
func WithDNS ¶
func WithDNS(dnsServers []string) CtrCreateOption
WithDNS sets additional name servers for the container
func WithDNSOption ¶
func WithDNSOption(dnsOptions []string) CtrCreateOption
WithDNSOption sets addition dns options for the container
func WithDNSSearch ¶
func WithDNSSearch(searchDomains []string) CtrCreateOption
WithDNSSearch sets the additional search domains of a container
func WithHosts ¶
func WithHosts(hosts []string) CtrCreateOption
WithHosts sets additional host:IP for the hosts file
func WithIPCNSFrom ¶
func WithIPCNSFrom(nsCtr *Container) CtrCreateOption
WithIPCNSFrom indicates the the container should join the IPC namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
func WithLabels ¶
func WithLabels(labels map[string]string) CtrCreateOption
WithLabels adds labels to the container
func WithLogPath ¶
func WithLogPath(path string) CtrCreateOption
WithLogPath sets the path to the log file
func WithMountNSFrom ¶
func WithMountNSFrom(nsCtr *Container) CtrCreateOption
WithMountNSFrom indicates the the container should join the mount namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
func WithNetNS ¶
func WithNetNS(portMappings []ocicni.PortMapping) CtrCreateOption
WithNetNS indicates that the container should be given a new network namespace with a minimal configuration An optional array of port mappings can be provided Conflicts with WithNetNSFrom()
func WithNetNSFrom ¶
func WithNetNSFrom(nsCtr *Container) CtrCreateOption
WithNetNSFrom indicates the the container should join the network namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
func WithPIDNSFrom ¶
func WithPIDNSFrom(nsCtr *Container) CtrCreateOption
WithPIDNSFrom indicates the the container should join the PID namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
func WithPrivileged ¶
func WithPrivileged(privileged bool) CtrCreateOption
WithPrivileged sets the privileged flag in the container runtime
func WithRootFSFromImage ¶
func WithRootFSFromImage(imageID string, imageName string, useImageVolumes bool) CtrCreateOption
WithRootFSFromImage sets up a fresh root filesystem using the given image If useImageConfig is specified, image volumes, environment variables, and other configuration from the image will be added to the config TODO: Replace image name and ID with a libpod.Image struct when that is finished
func WithSELinuxLabels ¶
func WithSELinuxLabels(processLabel, mountLabel string) CtrCreateOption
WithSELinuxLabels sets the mount label for SELinux
func WithShmDir ¶
func WithShmDir(dir string) CtrCreateOption
WithShmDir sets the directory that should be mounted on /dev/shm
func WithShmSize ¶
func WithShmSize(size int64) CtrCreateOption
WithShmSize sets the size of /dev/shm tmpfs mount
func WithStdin ¶
func WithStdin() CtrCreateOption
WithStdin keeps stdin on the container open to allow interaction
func WithStopSignal ¶
func WithStopSignal(signal syscall.Signal) CtrCreateOption
WithStopSignal sets the signal that will be sent to stop the container
func WithStopTimeout ¶
func WithStopTimeout(timeout uint) CtrCreateOption
WithStopTimeout sets the time to after initial stop signal is sent to container, before sending the kill signal
func WithUTSNSFrom ¶
func WithUTSNSFrom(nsCtr *Container) CtrCreateOption
WithUTSNSFrom indicates the the container should join the UTS namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
func WithUser ¶
func WithUser(user string) CtrCreateOption
WithUser sets the user identity field in configutation Valid uses [user | user:group | uid | uid:gid | user:gid | uid:group ]
func WithUserNSFrom ¶
func WithUserNSFrom(nsCtr *Container) CtrCreateOption
WithUserNSFrom indicates the the container should join the user namespace of the given container If the container has joined a pod, it can only join the namespaces of containers in the same pod
type Image ¶
type Image struct { Name string ID string Registry string ImageName string Tag string HasRegistry bool Transport string PullName string LocalName string // contains filtered or unexported fields }
Image describes basic attributes of an image
func (*Image) GetImageID ¶
GetImageID returns the image ID of the image
func (*Image) GetLocalImageName ¶
GetLocalImageName returns the name of the image if it is local as well as the image's ID. It will return an empty strings and error if not found.
func (*Image) GetManifest ¶
GetManifest tries to GET an images manifest, returns nil on success and err on failure
func (*Image) GetNameByID ¶
GetNameByID returns the name of the image when supplied the full or partion ID
type ImageFilter ¶
ImageFilter is a function to determine whether an image is included in command output. Images to be outputted are tested using the function. A true return will include the image, a false return will exclude it.
type ImageFilterParams ¶
type ImageFilterParams struct { Dangling string Label string BeforeImage time.Time SinceImage time.Time ReferencePattern string ImageName string ImageInput string }
ImageFilterParams contains the filter options that may be given when outputting images
type ImageResultFilter ¶ added in v0.2.2
type ImageResultFilter func(inspect.ImageResult) bool
ImageResultFilter is a mock function for image filtering
func ImageCreatedAfter ¶ added in v0.2.2
func ImageCreatedAfter(createTime time.Time) ImageResultFilter
ImageCreatedAfter allows you to filter on images created after the given time.Time
func ImageCreatedBefore ¶ added in v0.2.2
func ImageCreatedBefore(createTime time.Time) ImageResultFilter
ImageCreatedBefore allows you to filter on images created before the given time.Time
func ImageDangling ¶ added in v0.2.2
func ImageDangling() ImageResultFilter
ImageDangling allows you to filter images for dangling images
func ImageLabel ¶ added in v0.2.2
func ImageLabel(labelfilter string) ImageResultFilter
ImageLabel allows you to filter by images labels key and/or value
func OutputImageFilter ¶ added in v0.2.2
func OutputImageFilter(name string) ImageResultFilter
OutputImageFilter allows you to filter by an a specific image name
type InMemoryState ¶
type InMemoryState struct {
// contains filtered or unexported fields
}
An InMemoryState is a purely in-memory state store
func (*InMemoryState) AddContainer ¶
func (s *InMemoryState) AddContainer(ctr *Container) error
AddContainer adds a container to the state Containers in a pod cannot be added to the state
func (*InMemoryState) AddContainerToPod ¶
func (s *InMemoryState) AddContainerToPod(pod *Pod, ctr *Container) error
AddContainerToPod adds a container to the given pod, also adding it to the state
func (*InMemoryState) AddPod ¶
func (s *InMemoryState) AddPod(pod *Pod) error
AddPod adds a given pod to the state
func (*InMemoryState) AllContainers ¶
func (s *InMemoryState) AllContainers() ([]*Container, error)
AllContainers retrieves all containers from the state
func (*InMemoryState) AllPods ¶
func (s *InMemoryState) AllPods() ([]*Pod, error)
AllPods retrieves all pods currently in the state
func (*InMemoryState) Close ¶
func (s *InMemoryState) Close() error
Close the state before shutdown This is a no-op as we have no backing disk
func (*InMemoryState) Container ¶
func (s *InMemoryState) Container(id string) (*Container, error)
Container retrieves a container from its full ID
func (*InMemoryState) ContainerInUse ¶
func (s *InMemoryState) ContainerInUse(ctr *Container) ([]string, error)
ContainerInUse checks if the given container is being used by other containers
func (*InMemoryState) HasContainer ¶
func (s *InMemoryState) HasContainer(id string) (bool, error)
HasContainer checks if a container with the given ID is present in the state
func (*InMemoryState) HasPod ¶
func (s *InMemoryState) HasPod(id string) (bool, error)
HasPod checks if a pod with the given ID is present in the state
func (*InMemoryState) LookupContainer ¶
func (s *InMemoryState) LookupContainer(idOrName string) (*Container, error)
LookupContainer retrieves a container by full ID, unique partial ID, or name
func (*InMemoryState) LookupPod ¶
func (s *InMemoryState) LookupPod(idOrName string) (*Pod, error)
LookupPod retrieves a pod from the state from a full or unique partial ID or a full name
func (*InMemoryState) Pod ¶
func (s *InMemoryState) Pod(id string) (*Pod, error)
Pod retrieves a pod from the state from its full ID
func (*InMemoryState) PodContainers ¶
func (s *InMemoryState) PodContainers(pod *Pod) ([]*Container, error)
PodContainers retrieves the containers from a pod
func (*InMemoryState) PodContainersByID ¶
func (s *InMemoryState) PodContainersByID(pod *Pod) ([]string, error)
PodContainersByID returns the IDs of all containers in the given pod
func (*InMemoryState) PodHasContainer ¶
func (s *InMemoryState) PodHasContainer(pod *Pod, ctrID string) (bool, error)
PodHasContainer checks if the given pod has a container with the given ID
func (*InMemoryState) Refresh ¶
func (s *InMemoryState) Refresh() error
Refresh clears container and pod stats after a reboot In-memory state won't survive a reboot so this is a no-op
func (*InMemoryState) RemoveContainer ¶
func (s *InMemoryState) RemoveContainer(ctr *Container) error
RemoveContainer removes a container from the state The container will only be removed from the state, not from the pod the container belongs to
func (*InMemoryState) RemoveContainerFromPod ¶
func (s *InMemoryState) RemoveContainerFromPod(pod *Pod, ctr *Container) error
RemoveContainerFromPod removes the given container from the given pod The container is also removed from the state
func (*InMemoryState) RemovePod ¶
func (s *InMemoryState) RemovePod(pod *Pod) error
RemovePod removes a given pod from the state Only empty pods can be removed
func (*InMemoryState) RemovePodContainers ¶
func (s *InMemoryState) RemovePodContainers(pod *Pod) error
RemovePodContainers removes all containers from a pod This is used to simultaneously remove a number of containers with many interdependencies Will only remove containers if no dependencies outside of the pod are present
func (*InMemoryState) SaveContainer ¶
func (s *InMemoryState) SaveContainer(ctr *Container) error
SaveContainer saves a container's state As all state is in-memory, any changes are always reflected as soon as they are made As such this is a no-op
func (*InMemoryState) UpdateContainer ¶
func (s *InMemoryState) UpdateContainer(ctr *Container) error
UpdateContainer updates a container's state As all state is in-memory, no update will be required As such this is a no-op
type LinuxNS ¶
type LinuxNS int
LinuxNS represents a Linux namespace
const ( // InvalidNS is an invalid namespace InvalidNS LinuxNS = iota // IPCNS is the IPC namespace IPCNS LinuxNS = iota // MountNS is the mount namespace MountNS LinuxNS = iota // NetNS is the network namespace NetNS LinuxNS = iota // PIDNS is the PID namespace PIDNS LinuxNS = iota // UserNS is the user namespace UserNS LinuxNS = iota // UTSNS is the UTS namespace UTSNS LinuxNS = iota // CgroupNS is the CGroup namespace CgroupNS LinuxNS = iota )
type OCIRuntime ¶
type OCIRuntime struct {
// contains filtered or unexported fields
}
OCIRuntime represents an OCI-compatible runtime that libpod can call into to perform container operations
type Pod ¶
type Pod struct {
// contains filtered or unexported fields
}
Pod represents a group of containers that may share namespaces ffjson: skip
func (*Pod) AllContainers ¶
AllContainers retrieves the containers in the pod
func (*Pod) AllContainersByID ¶
AllContainersByID returns the container IDs of all the containers in the pod
func (*Pod) HasContainer ¶
HasContainer checks if a container is present in the pod
func (*Pod) Kill ¶
Kill sends a signal to all running containers within a pod Signals will only be sent to running containers. Containers that are not running will be ignored. All signals are sent independently, and sending will continue even if some containers encounter errors. An error and a map[string]error are returned If the error is not nil and the map is nil, an error was encountered before any containers were signalled If map is not nil, an error was encountered when signalling one or more containers. The container ID is mapped to the error encountered. The error is set to ErrCtrExists If both error and the map are nil, all containers were signalled successfully
func (*Pod) Start ¶
Start starts all containers within a pod Containers that are already running or have been paused are ignored All containers are started independently, in order dictated by their dependencies. An error and a map[string]error are returned If the error is not nil and the map is nil, an error was encountered before any containers were started If map is not nil, an error was encountered when starting one or more containers. The container ID is mapped to the error encountered. The error is set to ErrCtrExists If both error and the map are nil, all containers were started successfully
func (*Pod) Status ¶
func (p *Pod) Status() (map[string]ContainerStatus, error)
Status gets the status of all containers in the pod Returns a map of Container ID to Container Status
func (*Pod) Stop ¶
Stop stops all containers within a pod that are not already stopped Each container will use its own stop timeout Only running containers will be stopped. Paused, stopped, or created containers will be ignored. All containers are stopped independently. An error stopping one container will not prevent other containers being stopped. An error and a map[string]error are returned If the error is not nil and the map is nil, an error was encountered before any containers were stopped If map is not nil, an error was encountered when stopping one or more containers. The container ID is mapped to the error encountered. The error is set to ErrCtrExists If both error and the map are nil, all containers were stopped without error
type PodConfig ¶
type PodConfig struct { ID string `json:"id"` Name string `json:"name"` Labels map[string]string `json:""` }
PodConfig represents a pod's static configuration
func (*PodConfig) MarshalJSON ¶
MarshalJSON marshal bytes to json - template
func (*PodConfig) MarshalJSONBuf ¶
func (j *PodConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*PodConfig) UnmarshalJSON ¶
UnmarshalJSON umarshall json - template of ffjson
func (*PodConfig) UnmarshalJSONFFLexer ¶
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type PodCreateOption ¶
A PodCreateOption is a functional option which alters the Pod created by NewPod
func WithPodLabels ¶
func WithPodLabels(labels map[string]string) PodCreateOption
WithPodLabels sets the labels of a pod
func WithPodName ¶
func WithPodName(name string) PodCreateOption
WithPodName sets the name of the pod
type PodFilter ¶
PodFilter is a function to determine whether a pod is included in command output. Pods to be outputted are tested using the function. A true return will include the pod, a false return will exclude it.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the core libpod runtime
func NewRuntime ¶
func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error)
NewRuntime creates a new container runtime Options can be passed to override the default configuration for the runtime
func (*Runtime) GetAllContainers ¶
GetAllContainers is a helper function for GetContainers
func (*Runtime) GetConfig ¶
func (r *Runtime) GetConfig() *RuntimeConfig
GetConfig returns a copy of the configuration used by the runtime
func (*Runtime) GetContainer ¶
GetContainer retrieves a container by its ID
func (*Runtime) GetContainers ¶
func (r *Runtime) GetContainers(filters ...ContainerFilter) ([]*Container, error)
GetContainers retrieves all containers from the state Filters can be provided which will determine what containers are included in the output. Multiple filters are handled by ANDing their output, so only containers matching all filters are returned
func (*Runtime) GetContainersByList ¶
GetContainersByList is a helper function for GetContainers which takes a []string of container IDs or names
func (*Runtime) GetDiff ¶
GetDiff returns the differences between the two images, layers, or containers
func (*Runtime) GetHistory ¶
GetHistory gets the history of an image and information about its layers
func (*Runtime) GetImage ¶
GetImage retrieves an image matching the given name or hash from system storage If no matching image can be found, an error is returned
func (*Runtime) GetImageInspectInfo ¶
GetImageInspectInfo returns the inspect information of an image
func (*Runtime) GetImageRef ¶
GetImageRef searches for and returns a new types.Image matching the given name or ID in the given store.
func (*Runtime) GetImageResults ¶ added in v0.2.2
func (r *Runtime) GetImageResults() ([]inspect.ImageResult, error)
GetImageResults gets the images for podman images and returns them as an array of ImageResults
func (*Runtime) GetImages ¶
func (r *Runtime) GetImages(params *ImageFilterParams, filters ...ImageFilter) ([]*storage.Image, error)
GetImages retrieves all images present in storage Filters can be provided which will determine which images are included in the output. Multiple filters are handled by ANDing their output, so only images matching all filters are included
func (*Runtime) GetLatestContainer ¶
GetLatestContainer returns a container object of the latest created container.
func (*Runtime) GetRunningContainers ¶
GetRunningContainers is a helper function for GetContainers
func (*Runtime) HasContainer ¶
HasContainer checks if a container with the given ID is present
func (*Runtime) ImportImage ¶
func (r *Runtime) ImportImage(path string, options CopyOptions) error
ImportImage imports an OCI format image archive into storage as an image
func (*Runtime) IsImageID ¶
IsImageID determines if the input is a valid image ID. The input can be a full or partial image ID
func (*Runtime) LookupContainer ¶
LookupContainer looks up a container by its name or a partial ID If a partial ID is not unique, an error will be returned
func (*Runtime) LookupPod ¶
LookupPod retrieves a pod by its name or a partial ID If a partial ID is not unique, an error will be returned
func (*Runtime) NewContainer ¶
func (r *Runtime) NewContainer(rSpec *spec.Spec, options ...CtrCreateOption) (c *Container, err error)
NewContainer creates a new container from a given OCI config
func (*Runtime) NewPod ¶
func (r *Runtime) NewPod(options ...PodCreateOption) (*Pod, error)
NewPod makes a new, empty pod
func (*Runtime) ParseImageFilter ¶
func (r *Runtime) ParseImageFilter(imageInput, filter string) (*ImageFilterParams, error)
ParseImageFilter takes a set of images and a filter string as input, and returns the libpod.ImageFilterParams struct
func (*Runtime) Pods ¶
Pods retrieves all pods Filters can be provided which will determine which pods are included in the output. Multiple filters are handled by ANDing their output, so only pods matching all filters are returned
func (*Runtime) PullImage ¶
func (r *Runtime) PullImage(imgName string, options CopyOptions) (string, error)
PullImage pulls an image from configured registries By default, only the latest tag (or a specific tag if requested) will be pulled. If allTags is true, all tags for the requested image will be pulled. Signature validation will be performed if the Runtime has been appropriately configured
func (*Runtime) PushImage ¶
func (r *Runtime) PushImage(source string, destination string, options CopyOptions) error
PushImage pushes the given image to a location described by the given path
func (*Runtime) RemoveContainer ¶
RemoveContainer removes the given container If force is specified, the container will be stopped first Otherwise, RemoveContainer will return an error if the container is running
func (*Runtime) RemoveImage ¶
RemoveImage deletes an image from local storage Images being used by running containers can only be removed if force=true
func (*Runtime) RemovePod ¶
RemovePod removes a pod If removeCtrs is specified, containers will be removed Otherwise, a pod that is not empty will return an error and not be removed If force is specified with removeCtrs, all containers will be stopped before being removed Otherwise, the pod will not be removed if any containers are running
func (*Runtime) Shutdown ¶
Shutdown shuts down the runtime and associated containers and storage If force is true, containers and mounted storage will be shut down before cleaning up; if force is false, an error will be returned if there are still containers running or mounted
func (*Runtime) UntagImage ¶
UntagImage removes a tag from the given image
func (*Runtime) WithPod ¶
func (r *Runtime) WithPod(pod *Pod) CtrCreateOption
WithPod adds the container to a pod Containers which join a pod can only join the namespaces of other containers in the same pod
type RuntimeConfig ¶
type RuntimeConfig struct { StorageConfig storage.StoreOptions ImageDefaultTransport string SignaturePolicyPath string StateType RuntimeStateStore RuntimePath string ConmonPath string ConmonEnvVars []string CgroupManager string StaticDir string TmpDir string MaxLogSize int64 NoPivotRoot bool CNIConfigDir string CNIPluginDir []string }
RuntimeConfig contains configuration options used to set up the runtime
type RuntimeContainerMetadata ¶
type RuntimeContainerMetadata struct { // The provided name and the ID of the image that was used to // instantiate the container. ImageName string `json:"image-name"` // Applicable to both PodSandboxes and Containers ImageID string `json:"image-id"` // Applicable to both PodSandboxes and Containers // The container's name, which for an infrastructure container is usually PodName + "-infra". ContainerName string `json:"name"` // Applicable to both PodSandboxes and Containers, mandatory CreatedAt int64 `json:"created-at"` // Applicable to both PodSandboxes and Containers MountLabel string `json:"mountlabel,omitempty"` // Applicable to both PodSandboxes and Containers }
RuntimeContainerMetadata is the structure that we encode as JSON and store in the metadata field of storage.Container objects. It is used for specifying attributes containers when they are being created, and allows a container's MountLabel, and possibly other values, to be modified in one read/write cycle via calls to storageService.ContainerMetadata, RuntimeContainerMetadata.SetMountLabel, and storageService.SetContainerMetadata.
func (*RuntimeContainerMetadata) SetMountLabel ¶
func (metadata *RuntimeContainerMetadata) SetMountLabel(mountLabel string)
SetMountLabel updates the mount label held by a RuntimeContainerMetadata object.
type RuntimeOption ¶
A RuntimeOption is a functional option which alters the Runtime created by NewRuntime
func WithCNIConfigDir ¶
func WithCNIConfigDir(dir string) RuntimeOption
WithCNIConfigDir sets the CNI configuration directory
func WithCNIPluginDir ¶
func WithCNIPluginDir(dir string) RuntimeOption
WithCNIPluginDir sets the CNI plugins directory
func WithCgroupManager ¶
func WithCgroupManager(manager string) RuntimeOption
WithCgroupManager specifies the manager implementation name which is used to handle cgroups for containers Current valid values are "cgroupfs" and "systemd"
func WithConmonEnv ¶
func WithConmonEnv(environment []string) RuntimeOption
WithConmonEnv specifies the environment variable list for the conmon process
func WithConmonPath ¶
func WithConmonPath(path string) RuntimeOption
WithConmonPath specifies the path to the conmon binary which manages the runtime
func WithDefaultTransport ¶ added in v0.2.2
func WithDefaultTransport(defaultTransport string) RuntimeOption
WithDefaultTransport sets the default transport for retrieving images
func WithMaxLogSize ¶
func WithMaxLogSize(limit int64) RuntimeOption
WithMaxLogSize sets the maximum size of container logs Positive sizes are limits in bytes, -1 is unlimited
func WithNoPivotRoot ¶
func WithNoPivotRoot(noPivot bool) RuntimeOption
WithNoPivotRoot sets the runtime to use MS_MOVE instead of PIVOT_ROOT when starting containers
func WithOCIRuntime ¶
func WithOCIRuntime(runtimePath string) RuntimeOption
WithOCIRuntime specifies an OCI runtime to use for running containers
func WithSignaturePolicy ¶
func WithSignaturePolicy(path string) RuntimeOption
WithSignaturePolicy specifies the path of a file which decides how trust is managed for images we've pulled. If this is not specified, the system default configuration will be used instead
func WithStateType ¶
func WithStateType(storeType RuntimeStateStore) RuntimeOption
WithStateType sets the backing state implementation for libpod Please note that information is not portable between backing states As such, if this differs between two libpods running on the same system, they will not share containers, and unspecified behavior may occur
func WithStaticDir ¶
func WithStaticDir(dir string) RuntimeOption
WithStaticDir sets the directory that static runtime files which persist across reboots will be stored
func WithStorageConfig ¶
func WithStorageConfig(config storage.StoreOptions) RuntimeOption
WithStorageConfig uses the given configuration to set up container storage If this is not specified, the system default configuration will be used instead
func WithTmpDir ¶
func WithTmpDir(dir string) RuntimeOption
WithTmpDir sets the directory that temporary runtime files which are not expected to survive across reboots will be stored This should be located on a tmpfs mount (/tmp or /var/run for example)
type RuntimeStateStore ¶
type RuntimeStateStore int
RuntimeStateStore is a constant indicating which state store implementation should be used by libpod
const ( // InvalidStateStore is an invalid state store InvalidStateStore RuntimeStateStore = iota // InMemoryStateStore is an in-memory state that will not persist data // on containers and pods between libpod instances or after system // reboot InMemoryStateStore RuntimeStateStore = iota // SQLiteStateStore is a state backed by a SQLite database SQLiteStateStore RuntimeStateStore = iota // BoltDBStateStore is a state backed by a BoltDB database BoltDBStateStore RuntimeStateStore = iota // SeccompDefaultPath defines the default seccomp path SeccompDefaultPath = "/usr/share/containers/seccomp.json" // SeccompOverridePath if this exists it overrides the default seccomp path SeccompOverridePath = "/etc/crio/seccomp.json" )
type SQLState ¶
type SQLState struct {
// contains filtered or unexported fields
}
SQLState is a state implementation backed by a persistent SQLite3 database
func (*SQLState) AddContainer ¶
AddContainer adds the given container to the state If the container belongs to a pod, that pod must already be present in the state, and the container will be added to the pod
func (*SQLState) AddContainerToPod ¶
AddContainerToPod adds a container to the given pod
func (*SQLState) AllContainers ¶
AllContainers retrieves all the containers presently in the state
func (*SQLState) ContainerInUse ¶
ContainerInUse checks if other containers depend on the given container It returns the IDs of containers which depend on the given container
func (*SQLState) HasContainer ¶
HasContainer checks if the given container is present in the state It accepts a full ID
func (*SQLState) LookupContainer ¶
LookupContainer retrieves a container by full or unique partial ID or name
func (*SQLState) PodContainers ¶
PodContainers returns all the containers in a pod given the pod's full ID
func (*SQLState) PodContainersByID ¶
PodContainersByID returns the container IDs of all containers in the given pod
func (*SQLState) PodHasContainer ¶
PodHasContainer checks if the given pod containers a container with the given ID
func (*SQLState) Refresh ¶
Refresh clears the state after a reboot Resets mountpoint, PID, state, netns path for all containers
func (*SQLState) RemoveContainer ¶
RemoveContainer removes the given container from the state
func (*SQLState) RemoveContainerFromPod ¶
RemoveContainerFromPod removes a container from the given pod
func (*SQLState) RemovePodContainers ¶
RemovePodContainers removes all containers in a pod simultaneously This can avoid issues with dependencies within the pod The operation will fail if any container in the pod has a dependency from outside the pod
func (*SQLState) SaveContainer ¶
SaveContainer updates a container's state in the database
func (*SQLState) UpdateContainer ¶
UpdateContainer updates a container's state from the database
type State ¶
type State interface { // Close performs any pre-exit cleanup (e.g. closing database // connections) that may be required Close() error // Refresh clears container and pod states after a reboot Refresh() error // Return a container from the database from its full ID Container(id string) (*Container, error) // Return a container from the database by full or partial ID or full // name LookupContainer(idOrName string) (*Container, error) // Check if a container with the given full ID exists in the database HasContainer(id string) (bool, error) // Adds container to state // The container cannot be part of a pod // The container must have globally unique name and ID - pod names and // IDs also conflict with container names and IDs AddContainer(ctr *Container) error // Removes container from state // Containers that are part of pods must use RemoveContainerFromPod RemoveContainer(ctr *Container) error // UpdateContainer updates a container's state from the backing store UpdateContainer(ctr *Container) error // SaveContainer saves a container's current state to the backing store SaveContainer(ctr *Container) error // ContainerInUse checks if other containers depend upon a given // container // It returns a slice of the IDs of containers which depend on the given // container. If the slice is empty, no container depend on the given // container. // A container cannot be removed if other containers depend on it ContainerInUse(ctr *Container) ([]string, error) // Retrieves all containers presently in state AllContainers() ([]*Container, error) // Accepts full ID of pod Pod(id string) (*Pod, error) // Accepts full or partial IDs (as long as they are unique) and names LookupPod(idOrName string) (*Pod, error) // Checks if a pod with the given ID is present in the state HasPod(id string) (bool, error) // Check if a pod has a container with the given ID PodHasContainer(pod *Pod, ctrID string) (bool, error) // Get the IDs of all containers in a pod PodContainersByID(pod *Pod) ([]string, error) // Get all the containers in a pod PodContainers(pod *Pod) ([]*Container, error) // Adds pod to state AddPod(pod *Pod) error // Removes pod from state // Only empty pods can be removed from the state RemovePod(pod *Pod) error // Remove all containers from a pod // Used to simulataneously remove containers that might otherwise have // dependency issues // Will fail if a dependency outside the pod is encountered RemovePodContainers(pod *Pod) error // AddContainerToPod adds a container to an existing pod // The container given will be added to the state and the pod AddContainerToPod(pod *Pod, ctr *Container) error // RemoveContainerFromPod removes a container from an existing pod // The container will also be removed from the state RemoveContainerFromPod(pod *Pod, ctr *Container) error // Retrieves all pods presently in state AllPods() ([]*Pod, error) }
State is a storage backend for libpod's current state
func NewBoltState ¶
NewBoltState creates a new bolt-backed state database
func NewInMemoryState ¶
NewInMemoryState initializes a new, empty in-memory state
Source Files ¶
- boltdb_state.go
- boltdb_state_internal.go
- container.go
- container_api.go
- container_attach.go
- container_ffjson.go
- container_inspect.go
- container_internal.go
- container_top.go
- diff.go
- errors.go
- finished_64.go
- image_inspect.go
- in_memory_state.go
- info.go
- networking.go
- oci.go
- options.go
- pod.go
- pod_ffjson.go
- runc.go
- runtime.go
- runtime_ctr.go
- runtime_img.go
- runtime_pod.go
- sql_state.go
- sql_state_internal.go
- state.go
- stats.go
- storage.go
- test_common.go
- util.go