Documentation ¶
Index ¶
- Constants
- Variables
- func Copy(ociBinary string, ociID string, asset assets.CopyableFile) error
- func CreateContainer(ociBinary string, image string, opts ...CreateOpt) ([]string, error)
- func GetSubnets(networkName string) ([]string, error)
- func ImageID(containerNameOrID string) (string, error)
- func ImageInspect(containerNameOrID, format string) ([]string, error)
- func Inspect(ociBinary string, containerNameOrID, format string) ([]string, error)
- func NetworkInspect(networkNames []string, format string) ([]string, error)
- func Pause(ociBinary string, ociID string) error
- func PullIfNotPresent(ociBinary string, image string, forceUpdate bool, maxWait time.Duration) error
- func Remove(ociBinary string, ociID string) error
- func Save(ociBinary string, image, dest string) error
- func Status(ociBinary string, ociID string) (state.State, error)
- func Stop(ociBinary, ociID string) error
- func SystemStatus(ociBinary string, ociID string) (state.State, error)
- func UsernsRemap(ociBinary string) bool
- type CreateOpt
- type Mount
- type MountPropagation
- type PortMapping
Constants ¶
const ( Docker = "docker" Podman = "podman" )
Variables ¶
var MountPropagationNameToValue = map[string]MountPropagation{ "None": MountPropagationNone, "HostToContainer": MountPropagationHostToContainer, "Bidirectional": MountPropagationBidirectional, }
MountPropagationNameToValue is a map of valid MountPropogation names to their values
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 ¶
CreateContainer creates a container with "docker/podman run"
func GetSubnets ¶
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 ImageInspect ¶
ImageInspect return low-level information on containers images
func NetworkInspect ¶
NetworkInspect displays detailed information on one or more networks
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 SystemStatus ¶
SystemStatus checks if the oci container engine is running
func UsernsRemap ¶
UsernsRemap checks if userns-remap is enabled in dockerd
Types ¶
type CreateOpt ¶
type CreateOpt func(*createOpts) *createOpts
CreateOpt is an option for Create
func WithPortMappings ¶
func WithPortMappings(portMappings []PortMapping) CreateOpt
WithPortMappings sets the container port mappings to the host
func WithRunArgs ¶
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