oci

package
v1.7.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Docker = "docker"
	Podman = "podman"
)

Variables

View Source
var MountPropagationNameToValue = map[string]MountPropagation{
	"None":            MountPropagationNone,
	"HostToContainer": MountPropagationHostToContainer,
	"Bidirectional":   MountPropagationBidirectional,
}

MountPropagationNameToValue is a map of valid MountPropogation names to their values

View Source
var MountPropagationValueToName = map[MountPropagation]string{
	MountPropagationNone:            "None",
	MountPropagationHostToContainer: "HostToContainer",
	MountPropagationBidirectional:   "Bidirectional",
}

MountPropagationValueToName is a map of valid MountPropogation values to their string names

Functions

func Copy

func Copy(ociBinary string, ociID string, asset assets.CopyableFile) error

Copy copies a local asset into the container

func CreateContainer

func CreateContainer(ociBinary string, image string, opts ...CreateOpt) ([]string, error)

CreateContainer creates a container with "docker/podman run"

func GetSubnets

func GetSubnets(networkName string) ([]string, error)

GetSubnets returns a slice of subnets for a specified network name For example the command : docker network inspect -f '{{range (index (index . "IPAM") "Config")}}{{index . "Subnet"}} {{end}}' bridge returns 172.17.0.0/16

func ImageID

func ImageID(containerNameOrID string) (string, error)

ImageID return the Id of the container image

func ImageInspect

func ImageInspect(containerNameOrID, format string) ([]string, error)

ImageInspect return low-level information on containers images

func Inspect

func Inspect(ociBinary string, containerNameOrID, format string) ([]string, error)

Inspect return low-level information on containers

func NetworkInspect

func NetworkInspect(networkNames []string, format string) ([]string, error)

NetworkInspect displays detailed information on one or more networks

func Pause

func Pause(ociBinary string, ociID string) error

Pause pauses a container

func PullIfNotPresent

func PullIfNotPresent(ociBinary string, image string, forceUpdate bool, maxWait time.Duration) error

PullIfNotPresent pulls docker image if not present back off exponentially

func Remove

func Remove(ociBinary string, ociID string) error

Remove removes a container

func Save

func Save(ociBinary string, image, dest string) error

Save saves an image archive "docker/podman save"

func Status

func Status(ociBinary string, ociID string) (state.State, error)

Status returns the status of the container

func Stop

func Stop(ociBinary, ociID string) error

Stop stops a container

func SystemStatus

func SystemStatus(ociBinary string, ociID string) (state.State, error)

SystemStatus checks if the oci container engine is running

func UsernsRemap

func UsernsRemap(ociBinary string) bool

UsernsRemap checks if userns-remap is enabled in dockerd

Types

type CreateOpt

type CreateOpt func(*createOpts) *createOpts

CreateOpt is an option for Create

func WithMounts

func WithMounts(mounts []Mount) CreateOpt

WithMounts sets the container mounts

func WithPortMappings

func WithPortMappings(portMappings []PortMapping) CreateOpt

WithPortMappings sets the container port mappings to the host

func WithRunArgs

func WithRunArgs(args ...string) CreateOpt

WithRunArgs sets the args for docker run as in the args portion of `docker run args... image containerArgs...`

type Mount

type Mount struct {
	// Path of the mount within the container.
	ContainerPath string `protobuf:"bytes,1,opt,name=container_path,json=containerPath,proto3" json:"containerPath,omitempty"`
	// Path of the mount on the host. If the hostPath doesn't exist, then runtimes
	// should report error. If the hostpath is a symbolic link, runtimes should
	// follow the symlink and mount the real destination to container.
	HostPath string `protobuf:"bytes,2,opt,name=host_path,json=hostPath,proto3" json:"hostPath,omitempty"`
	// If set, the mount is read-only.
	Readonly bool `protobuf:"varint,3,opt,name=readonly,proto3,json=readOnly,proto3" json:"readOnly,omitempty"`
	// If set, the mount needs SELinux relabeling.
	SelinuxRelabel bool `protobuf:"varint,4,opt,name=selinux_relabel,json=selinuxRelabel,proto3" json:"selinuxRelabel,omitempty"`
	// Requested propagation mode.
	Propagation MountPropagation `protobuf:"varint,5,opt,name=propagation,proto3,enum=runtime.v1alpha2.MountPropagation" json:"propagation,omitempty"`
}

Mount specifies a host volume to mount into a container. This is a close copy of the upstream cri Mount type see: k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2 It additionally serializes the "propagation" field with the string enum names on disk as opposed to the int32 values, and the serlialzed field names have been made closer to core/v1 VolumeMount field names In yaml this looks like:

containerPath: /foo
hostPath: /bar
readOnly: true
selinuxRelabel: false
propagation: None

Propagation may be one of: None, HostToContainer, Bidirectional

type MountPropagation

type MountPropagation int32

MountPropagation represents an "enum" for mount propagation options, see also Mount.

const (
	// MountPropagationNone specifies that no mount propagation
	// ("private" in Linux terminology).
	MountPropagationNone MountPropagation = 0
	// MountPropagationHostToContainer specifies that mounts get propagated
	// from the host to the container ("rslave" in Linux).
	MountPropagationHostToContainer MountPropagation = 1
	// MountPropagationBidirectional specifies that mounts get propagated from
	// the host to the container and from the container to the host
	// ("rshared" in Linux).
	MountPropagationBidirectional MountPropagation = 2
)

type PortMapping

type PortMapping struct {
	// Port within the container.
	ContainerPort int32 `protobuf:"varint,1,opt,name=container_port,json=containerPort,proto3" json:"containerPort,omitempty"`
	// Port on the host.
	HostPort      int32  `protobuf:"varint,2,opt,name=host_path,json=hostPort,proto3" json:"hostPort,omitempty"`
	ListenAddress string `protobuf:"bytes,3,opt,name=listenAddress,json=hostPort,proto3" json:"listenAddress,omitempty"`
}

PortMapping specifies a host port mapped into a container port. In yaml this looks like:

containerPort: 80
hostPort: 8000
listenAddress: 127.0.0.1

Jump to

Keyboard shortcuts

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