{"modulePath":"github.com/ssdev-go/moby","version":"v1.10.3","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package execdriver\n\n## Variables\n\n```go\nvar (\n\tErrNotRunning              = errors.New(\"Container is not running\")\n\tErrWaitTimeoutReached      = errors.New(\"Wait timeout reached\")\n\tErrDriverAlreadyRegistered = errors.New(\"A driver already registered this docker init function\")\n\tErrDriverNotFound          = errors.New(\"The requested docker init has not been found\")\n)\n```\nDefine error messages\n\n## Functions\n\n```go\nfunc GetAllCapabilities() []string\n```\nGetAllCapabilities returns all of the capabilities\n\n```go\nfunc InitContainer(c *Command) *configs.Config\n```\nInitContainer is the initialization of a container config. It returns the initial configs for a container. It's mostly defined by the default template.\n\n```go\nfunc SetRootPropagation(config *configs.Config, propagation int)\n```\nSetRootPropagation sets the root mount propagation mode.\n\n```go\nfunc SetupCgroups(container *configs.Config, c *Command) error\n```\nSetupCgroups setups cgroup resources for a container.\n\n```go\nfunc TweakCapabilities(basics, adds, drops []string) ([]string, error)\n```\nTweakCapabilities can tweak capabilities by adding or dropping capabilities based on the basics capabilities.\n\n## Types\n\n```go\ntype Capabilities []*CapabilityMapping\n```\nCapabilities contains all CapabilityMapping\n\n```go\ntype CapabilityMapping struct {\n\tKey   string         `json:\"key,omitempty\"`\n\tValue capability.Cap `json:\"value,omitempty\"`\n}\n```\nCapabilityMapping maps linux capability name to its value of capability.Cap type Capabilities is one of the security systems in Linux Security Module (LSM) framework provided by the kernel. For more details on capabilities, see [http://man7.org/linux/man-pages/man7/capabilities.7.html](http://man7.org/linux/man-pages/man7/capabilities.7.html)\n\n```go\nfunc GetCapability(key string) *CapabilityMapping\n```\nGetCapability returns CapabilityMapping which contains specific key\n\n```go\nfunc (c *CapabilityMapping) String() string\n```\nString returns \\\u003ckey\u003e of CapabilityMapping\n\n```go\ntype Command struct {\n\tCommonCommand\n\n\tAllowedDevices     []*configs.Device `json:\"allowed_devices\"`\n\tAppArmorProfile    string            `json:\"apparmor_profile\"`\n\tAutoCreatedDevices []*configs.Device `json:\"autocreated_devices\"`\n\tCapAdd             []string          `json:\"cap_add\"`\n\tCapDrop            []string          `json:\"cap_drop\"`\n\tCgroupParent       string            `json:\"cgroup_parent\"` // The parent cgroup for this command.\n\tGIDMapping         []idtools.IDMap   `json:\"gidmapping\"`\n\tGroupAdd           []string          `json:\"group_add\"`\n\tIpc                *Ipc              `json:\"ipc\"`\n\tOomScoreAdj        int               `json:\"oom_score_adj\"`\n\tPid                *Pid              `json:\"pid\"`\n\tReadonlyRootfs     bool              `json:\"readonly_rootfs\"`\n\tRemappedRoot       *User             `json:\"remap_root\"`\n\tSeccompProfile     string            `json:\"seccomp_profile\"`\n\tUIDMapping         []idtools.IDMap   `json:\"uidmapping\"`\n\tUTS                *UTS              `json:\"uts\"`\n}\n```\nCommand wraps an os/exec.Cmd to add more metadata\n\n```go\ntype CommonCommand struct {\n\tContainerPid  int           `json:\"container_pid\"` // the pid for the process inside a container\n\tID            string        `json:\"id\"`\n\tInitPath      string        `json:\"initpath\"`    // dockerinit\n\tMountLabel    string        `json:\"mount_label\"` // TODO Windows. More involved, but can be factored out\n\tMounts        []Mount       `json:\"mounts\"`\n\tNetwork       *Network      `json:\"network\"`\n\tProcessConfig ProcessConfig `json:\"process_config\"` // Describes the init process of the container.\n\tProcessLabel  string        `json:\"process_label\"`  // TODO Windows. More involved, but can be factored out\n\tResources     *Resources    `json:\"resources\"`\n\tRootfs        string        `json:\"rootfs\"` // root fs of the container\n\tWorkingDir    string        `json:\"working_dir\"`\n\tTmpDir        string        `json:\"tmpdir\"` // Directory used to store docker tmpdirs.\n}\n```\nCommonCommand is the common platform agnostic part of the Command structure which wraps an os/exec.Cmd to add more metadata\n\n```go\ntype CommonProcessConfig struct {\n\texec.Cmd `json:\"-\"`\n\n\tTty        bool     `json:\"tty\"`\n\tEntrypoint string   `json:\"entrypoint\"`\n\tArguments  []string `json:\"arguments\"`\n\tTerminal   Terminal `json:\"-\"` // standard or tty terminal\n}\n```\nCommonProcessConfig is the common platform agnostic part of the ProcessConfig structure that describes a process that will be run inside a container.\n\n```go\ntype CommonResources struct {\n\tMemory            int64  `json:\"memory\"`\n\tMemoryReservation int64  `json:\"memory_reservation\"`\n\tCPUShares         int64  `json:\"cpu_shares\"`\n\tBlkioWeight       uint16 `json:\"blkio_weight\"`\n}\n```\nCommonResources contains the resource configs for a driver that are common across platforms.\n\n```go\ntype Context map[string]string\n```\nContext is a generic key value pair that allows arbitrary data to be sent\n\n```go\ntype Driver interface {\n\t// Run executes the process, blocks until the process exits and returns\n\t// the exit code. It's the last stage on Docker side for running a container.\n\tRun(c *Command, pipes *Pipes, hooks Hooks) (ExitStatus, error)\n\n\t// Exec executes the process in an existing container, blocks until the\n\t// process exits and returns the exit code.\n\tExec(c *Command, processConfig *ProcessConfig, pipes *Pipes, hooks Hooks) (int, error)\n\n\t// Kill sends signals to process in container.\n\tKill(c *Command, sig int) error\n\n\t// Pause pauses a container.\n\tPause(c *Command) error\n\n\t// Unpause unpauses a container.\n\tUnpause(c *Command) error\n\n\t// Name returns the name of the driver.\n\tName() string\n\n\t// Info returns the configuration stored in the driver struct,\n\t// \"temporary\" hack (until we move state from core to plugins).\n\tInfo(id string) Info\n\n\t// GetPidsForContainer returns a list of pid for the processes running in a container.\n\tGetPidsForContainer(id string) ([]int, error)\n\n\t// Terminate kills a container by sending signal SIGKILL.\n\tTerminate(c *Command) error\n\n\t// Clean removes all traces of container exec.\n\tClean(id string) error\n\n\t// Stats returns resource stats for a running container\n\tStats(id string) (*ResourceStats, error)\n\n\t// Update updates resource configs for a container\n\tUpdate(c *Command) error\n\n\t// SupportsHooks refers to the driver capability to exploit pre/post hook functionality\n\tSupportsHooks() bool\n}\n```\nDriver is an interface for drivers to implement including all basic functions a driver should have\n\n```go\ntype DriverCallback func(processConfig *ProcessConfig, pid int, chOOM \u003c-chan struct{}) error\n```\nDriverCallback defines a callback function which is used in \"Run\" and \"Exec\". This allows work to be done in the parent process when the child is passing through PreStart, Start and PostStop events. Callbacks are provided a processConfig pointer and the pid of the child. The channel will be used to notify the OOM events.\n\n```go\ntype ExitStatus struct {\n\t// The exit code with which the container exited.\n\tExitCode int\n\n\t// Whether the container encountered an OOM.\n\tOOMKilled bool\n}\n```\nExitStatus provides exit reasons for a container.\n\n```go\ntype Hooks struct {\n\t// PreStart is called before container's CMD/ENTRYPOINT is executed\n\tPreStart []DriverCallback\n\t// Start is called after the container's process is full started\n\tStart DriverCallback\n\t// PostStop is called after the container process exits\n\tPostStop []DriverCallback\n}\n```\nHooks is a struct containing function pointers to callbacks used by any execdriver implementation exploiting hooks capabilities\n\n```go\ntype Info interface {\n\tIsRunning() bool\n}\n```\nInfo is driver specific information based on processes registered with the driver\n\n```go\ntype Ipc struct {\n\tContainerID string `json:\"container_id\"` // id of the container to join ipc.\n\tHostIpc     bool   `json:\"host_ipc\"`\n}\n```\nIpc settings of the container It is for IPC namespace setting. Usually different containers have their own IPC namespace, however this specifies to use an existing IPC namespace. You can join the host's or a container's IPC namespace.\n\n```go\ntype Mount struct {\n\tSource      string `json:\"source\"`\n\tDestination string `json:\"destination\"`\n\tWritable    bool   `json:\"writable\"`\n\tData        string `json:\"data\"`\n\tPropagation string `json:\"mountpropagation\"`\n}\n```\nMount contains information for a mount operation.\n\n```go\ntype Network struct {\n\tMtu            int    `json:\"mtu\"`\n\tContainerID    string `json:\"container_id\"` // id of the container to join network.\n\tNamespacePath  string `json:\"namespace_path\"`\n\tHostNetworking bool   `json:\"host_networking\"`\n}\n```\nNetwork settings of the container\n\n```go\ntype Pid struct {\n\tHostPid bool `json:\"host_pid\"`\n}\n```\nPid settings of the container It is for PID namespace setting. Usually different containers have their own PID namespace, however this specifies to use an existing PID namespace. Joining the host's PID namespace is currently the only supported option.\n\n```go\ntype Pipes struct {\n\tStdin          io.ReadCloser\n\tStdout, Stderr io.Writer\n}\n```\nPipes is a wrapper around a container's output for stdin, stdout, stderr\n\n```go\nfunc NewPipes(stdin io.ReadCloser, stdout, stderr io.Writer, useStdin bool) *Pipes\n```\nNewPipes returns a wrapper around a container's output\n\n```go\ntype ProcessConfig struct {\n\tCommonProcessConfig\n\n\t// Fields below here are platform specific\n\tPrivileged bool   `json:\"privileged\"`\n\tUser       string `json:\"user\"`\n\tConsole    string `json:\"-\"` // dev/console path\n}\n```\nProcessConfig is the platform specific structure that describes a process that will be run inside a container.\n\n```go\ntype ResourceStats struct {\n\t*libcontainer.Stats\n\tRead        time.Time `json:\"read\"`\n\tMemoryLimit int64     `json:\"memory_limit\"`\n\tSystemUsage uint64    `json:\"system_usage\"`\n}\n```\nResourceStats contains information about resource usage by a container.\n\n```go\nfunc Stats(containerDir string, containerMemoryLimit int64, machineMemory int64) (*ResourceStats, error)\n```\nStats collects all the resource usage information from a container.\n\n```go\ntype Resources struct {\n\tCommonResources\n\n\tBlkioWeightDevice            []*blkiodev.WeightDevice   `json:\"blkio_weight_device\"`\n\tBlkioThrottleReadBpsDevice   []*blkiodev.ThrottleDevice `json:\"blkio_throttle_read_bps_device\"`\n\tBlkioThrottleWriteBpsDevice  []*blkiodev.ThrottleDevice `json:\"blkio_throttle_write_bps_device\"`\n\tBlkioThrottleReadIOpsDevice  []*blkiodev.ThrottleDevice `json:\"blkio_throttle_read_iops_device\"`\n\tBlkioThrottleWriteIOpsDevice []*blkiodev.ThrottleDevice `json:\"blkio_throttle_write_iops_device\"`\n\tMemorySwap                   int64                      `json:\"memory_swap\"`\n\tKernelMemory                 int64                      `json:\"kernel_memory\"`\n\tCPUQuota                     int64                      `json:\"cpu_quota\"`\n\tCpusetCpus                   string                     `json:\"cpuset_cpus\"`\n\tCpusetMems                   string                     `json:\"cpuset_mems\"`\n\tCPUPeriod                    int64                      `json:\"cpu_period\"`\n\tRlimits                      []*units.Rlimit            `json:\"rlimits\"`\n\tOomKillDisable               bool                       `json:\"oom_kill_disable\"`\n\tMemorySwappiness             int64                      `json:\"memory_swappiness\"`\n}\n```\nResources contains all resource configs for a driver. Currently these are all for cgroup configs.\n\n```go\ntype StdConsole struct {\n\t// Closers holds io.Closer references for closing at terminal close time\n\tClosers []io.Closer\n}\n```\nStdConsole defines standard console operations for execdriver\n\n```go\nfunc NewStdConsole(processConfig *ProcessConfig, pipes *Pipes) (*StdConsole, error)\n```\nNewStdConsole returns a new StdConsole struct\n\n```go\nfunc (s *StdConsole) AttachPipes(command *exec.Cmd, pipes *Pipes) error\n```\nAttachPipes attaches given pipes to exec.Cmd\n\n```go\nfunc (s *StdConsole) Close() error\n```\nClose implements Close method of Terminal interface\n\n```go\nfunc (s *StdConsole) Resize(h, w int) error\n```\nResize implements Resize method of Terminal interface\n\n```go\ntype Terminal interface {\n\tio.Closer\n\tResize(height, width int) error\n}\n```\nTerminal represents a pseudo TTY, it is for when using a container interactively.\n\n```go\ntype UTS struct {\n\tHostUTS bool `json:\"host_uts\"`\n}\n```\nUTS settings of the container It is for UTS namespace setting. Usually different containers have their own UTS namespace, however this specifies to use an existing UTS namespace. Joining the host's UTS namespace is currently the only supported option.\n\n```go\ntype User struct {\n\tUID int `json:\"root_uid\"`\n\tGID int `json:\"root_gid\"`\n}\n```\nUser contains the uid and gid representing a Unix user\n\n","path":"github.com/ssdev-go/moby/daemon/execdriver","name":"execdriver","synopsis":"","isRedistributable":true}
