container

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package container encapuslates both the metadata structure and main operations to be presented to the user in the `cmd` module.

Copyright © 2022 Joel D. Elkins <joel@elkins.co>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Category   string            `toml:"category"`
	Name       string            `toml:"name"`
	Image      string            `toml:"image"`
	Hostname   string            `toml:"hostname,omitempty"`
	Command    []string          `toml:"cmd,omitempty"`
	Arguments  string            `toml:"arguments,omitempty"`
	Networks   []network.Network `toml:"networks,omitempty"`
	Env        map[string]string `toml:"env,omitempty"`
	Mounts     []specs.Mount     `toml:"mounts,omitempty"`
	Restart    string            `toml:"restart,omitempty"`
	Umask      null.Int          `toml:"umask,omitempty"`
	User       string            `toml:"user,omitempty"`
	ExposeTCP  []uint16          `toml:"expose_tcp,omitempty"`
	ExposeUDP  []uint16          `toml:"expose_udp,omitempty"`
	PortsTCP   map[uint16]uint16 `toml:"ports,omitempty"`
	NetNS      string            `toml:"netns,omitempty"`
	StartGroup int               `toml:"group,omitempty"`
	Devices    []string          `toml:"devices,omitempty"`
	CapAdd     []string          `toml:"cap_add,omitempty"`
	Privileged null.Bool         `toml:"privileged,omitempty"`
	Sysctl     map[string]string `toml:"sysctl,omitempty"`
	DomainName string            `toml:"domain_name,omitempty"`
	DnsServer  string            `toml:"dns_server,omitempty"`
	TSIGName   string            `toml:"tsig_name,omitempty"`
	TSIGKey    string            `toml:"tsig_key,omitempty"`
	// contains filtered or unexported fields
}

Container houses the metadata that may be specified by this utility when creating a container. A couple of fields (Name and Image) are mandatory to specify, but the rest will use the libpod or otherwise sensible defaults.

func (*Container) ConditionalStartCommands added in v1.2.0

func (c *Container) ConditionalStartCommands() cmd.Set

ConditionalStartCommands - several of the other command sets would leave the container in the stopped state. This set will restart a container if it was running when this container was first initialized.

func (*Container) CreateCommands

func (c *Container) CreateCommands() cmd.Set

CreateCommands returns a cmd.Set that will create a container from the configured metadata. The container should not exist.

func (*Container) GetStats added in v1.4.0

func (c *Container) GetStats() *define.ContainerStats

func (*Container) Init

func (c *Container) Init(conn context.Context, nets []*network.Network, domain_name string, dns_server string, tsig_name string, tsig_key string) error

Init will initialize a new container structure by filling in network details and by querying other metadata from libpod, if possible.

func (*Container) IsCreated added in v1.1.0

func (c *Container) IsCreated() bool

IsCreated tests whether libpod sees the container as being created (running or not)

func (*Container) IsRunning added in v1.0.8

func (c *Container) IsRunning() bool

IsRunning returns true if libpod reports the container status is running, or false otherwise. If an error happens (e.g. the container is not created), the default value is false.

func (*Container) LogEntry added in v1.1.1

func (c *Container) LogEntry() *log.Entry

LogEntry will return a *logrus.LogEntry, with some basic fields populated for this container. The idea is that the calling code would add other fields (optionally) and do something with the error.

func (*Container) NsUpdateCommands added in v1.2.90

func (c *Container) NsUpdateCommands() cmd.Set

func (*Container) Pid

func (c *Container) Pid() int

Pid will return the host process id of the main container process (pid 1 inside the container)

func (*Container) PullCommands added in v1.1.2

func (c *Container) PullCommands() cmd.Set

PullCommands will return a cmd.Set to pull the specified image using the libpod API

func (*Container) RecreateCommands

func (c *Container) RecreateCommands() cmd.Set

RecreateCommands will stop (if running), remove (if exists), (re)create, and restart (if it was initially running) a container. The image is not pulled.

func (*Container) RemoveCommands added in v1.1.9

func (c *Container) RemoveCommands() cmd.Set

RemoveCommands removes a container (as if by `podman rm -f`)

func (*Container) RunningTime added in v1.4.0

func (c *Container) RunningTime() time.Duration

func (*Container) StartCommands

func (c *Container) StartCommands() cmd.Set

StartCommands will start a container if it's not already running.

func (*Container) StopCommands

func (c *Container) StopCommands() cmd.Set

StopCommands will stop a container if it is running, defining a 10 second timeout before the processes are killed by lippod

func (*Container) UpdateCommands

func (c *Container) UpdateCommands() cmd.Set

UpdateCommands will pull the image (to force updates) and then recreate the container. It will be stopped first.

Jump to

Keyboard shortcuts

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