{"modulePath":"github.com/docker/containerd","version":"v0.2.8","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package runtime\n\n## Constants\n\n```go\nconst (\n\t// ExitFile holds the name of the pipe used to monitor process\n\t// exit\n\tExitFile = \"exit\"\n\t// ExitStatusFile holds the name of the file where the container\n\t// exit code is to be written\n\tExitStatusFile = \"exitStatus\"\n\t// StateFile holds the name of the file where the container state\n\t// is written\n\tStateFile = \"state.json\"\n\t// ControlFile holds the name of the pipe used to control the shim\n\tControlFile = \"control\"\n\t// InitProcessID holds the special ID used for the very first\n\t// container's process\n\tInitProcessID = \"init\"\n\t// StartTimeFile holds the name of the file in which the process\n\t// start time is saved\n\tStartTimeFile = \"starttime\"\n\n\t// UnknownStatus is the value returned when a process exit\n\t// status cannot be determined\n\tUnknownStatus = 255\n)\n```\n\n```go\nconst (\n\tPaused  = State(\"paused\")\n\tStopped = State(\"stopped\")\n\tRunning = State(\"running\")\n)\n```\nPossible container states\n\n## Variables\n\n```go\nvar (\n\t// ErrContainerExited is returned when access to an exited\n\t// container is attempted\n\tErrContainerExited = errors.New(\"containerd: container has exited\")\n\t// ErrProcessNotExited is returned when trying to retrieve the exit\n\t// status of an alive process\n\tErrProcessNotExited = errors.New(\"containerd: process has not exited\")\n\t// ErrContainerNotStarted is returned when a container fails to\n\t// start without error from the shim or the OCI runtime\n\tErrContainerNotStarted = errors.New(\"containerd: container not started\")\n\t// ErrContainerStartTimeout is returned if a container takes too\n\t// long to start\n\tErrContainerStartTimeout = errors.New(\"containerd: container did not start before the specified timeout\")\n\t// ErrShimExited is returned if the shim or the contianer's init process\n\t// exits before completing\n\tErrShimExited = errors.New(\"containerd: shim exited before container process was started\")\n)\n```\n\n## Types\n\n```go\ntype Blkio struct {\n\tIoServiceBytesRecursive []BlkioEntry `json:\"ioServiceBytesRecursive,omitempty\"`\n\tIoServicedRecursive     []BlkioEntry `json:\"ioServicedRecursive,omitempty\"`\n\tIoQueuedRecursive       []BlkioEntry `json:\"ioQueueRecursive,omitempty\"`\n\tIoServiceTimeRecursive  []BlkioEntry `json:\"ioServiceTimeRecursive,omitempty\"`\n\tIoWaitTimeRecursive     []BlkioEntry `json:\"ioWaitTimeRecursive,omitempty\"`\n\tIoMergedRecursive       []BlkioEntry `json:\"ioMergedRecursive,omitempty\"`\n\tIoTimeRecursive         []BlkioEntry `json:\"ioTimeRecursive,omitempty\"`\n\tSectorsRecursive        []BlkioEntry `json:\"sectorsRecursive,omitempty\"`\n}\n```\nBlkio regroups all the Blkio related stats\n\n```go\ntype BlkioEntry struct {\n\tMajor uint64 `json:\"major,omitempty\"`\n\tMinor uint64 `json:\"minor,omitempty\"`\n\tOp    string `json:\"op,omitempty\"`\n\tValue uint64 `json:\"value,omitempty\"`\n}\n```\nBlkioEntry represents a single record for a Blkio stat\n\n```go\ntype CPU struct {\n\tUsage      CPUUsage   `json:\"usage,omitempty\"`\n\tThrottling Throttling `json:\"throttling,omitempty\"`\n}\n```\nCPU regroups both a CPU usage and throttling information\n\n```go\ntype CPUUsage struct {\n\t// Units: nanoseconds.\n\tTotal  uint64   `json:\"total,omitempty\"`\n\tPercpu []uint64 `json:\"percpu,omitempty\"`\n\tKernel uint64   `json:\"kernel\"`\n\tUser   uint64   `json:\"user\"`\n}\n```\nCPUUsage holds information regarding cpu usage\n\n```go\ntype Checkpoint struct {\n\t// Timestamp is the time that checkpoint happened\n\tCreated time.Time `json:\"created\"`\n\t// Name is the name of the checkpoint\n\tName string `json:\"name\"`\n\t// TCP checkpoints open tcp connections\n\tTCP bool `json:\"tcp\"`\n\t// UnixSockets persists unix sockets in the checkpoint\n\tUnixSockets bool `json:\"unixSockets\"`\n\t// Shell persists tty sessions in the checkpoint\n\tShell bool `json:\"shell\"`\n\t// Exit exits the container after the checkpoint is finished\n\tExit bool `json:\"exit\"`\n\t// EmptyNS tells CRIU to omit a specified namespace\n\tEmptyNS []string `json:\"emptyNS,omitempty\"`\n}\n```\nCheckpoint holds information regarding a container checkpoint\n\n```go\ntype Container interface {\n\t// ID returns the container ID\n\tID() string\n\t// Path returns the path to the bundle\n\tPath() string\n\t// Start starts the init process of the container\n\tStart(ctx context.Context, checkpointPath string, s Stdio) (Process, error)\n\t// Exec starts another process in an existing container\n\tExec(context.Context, string, specs.ProcessSpec, Stdio) (Process, error)\n\t// Delete removes the container's state and any resources\n\tDelete() error\n\t// Processes returns all the containers processes that have been added\n\tProcesses() ([]Process, error)\n\t// State returns the containers runtime state\n\tState() State\n\t// Resume resumes a paused container\n\tResume() error\n\t// Pause pauses a running container\n\tPause() error\n\t// RemoveProcess removes the specified process from the container\n\tRemoveProcess(string) error\n\t// Checkpoints returns all the checkpoints for a container\n\tCheckpoints(checkpointDir string) ([]Checkpoint, error)\n\t// Checkpoint creates a new checkpoint\n\tCheckpoint(checkpoint Checkpoint, checkpointDir string) error\n\t// DeleteCheckpoint deletes the checkpoint for the provided name\n\tDeleteCheckpoint(name string, checkpointDir string) error\n\t// Labels are user provided labels for the container\n\tLabels() []string\n\t// Pids returns all pids inside the container\n\tPids() ([]int, error)\n\t// Stats returns realtime container stats and resource information\n\tStats() (*Stat, error)\n\t// Name or path of the OCI compliant runtime used to execute the container\n\tRuntime() string\n\t// OOM signals the channel if the container received an OOM notification\n\tOOM() (OOM, error)\n\t// UpdateResource updates the containers resources to new values\n\tUpdateResources(*Resource) error\n\n\t// Status return the current status of the container.\n\tStatus() (State, error)\n}\n```\nContainer defines the operations allowed on a container\n\n```go\nfunc Load(root, id, shimName string, timeout time.Duration) (Container, error)\n```\nLoad return a new container from the matchin state file on disk.\n\n```go\nfunc New(opts ContainerOpts) (Container, error)\n```\nNew returns a new container\n\n```go\ntype ContainerOpts struct {\n\tRoot        string\n\tID          string\n\tBundle      string\n\tRuntime     string\n\tRuntimeArgs []string\n\tShim        string\n\tLabels      []string\n\tNoPivotRoot bool\n\tTimeout     time.Duration\n}\n```\nContainerOpts keeps the options passed at container creation\n\n```go\ntype Hugetlb struct {\n\tUsage   uint64 `json:\"usage,omitempty\"`\n\tMax     uint64 `json:\"max,omitempty\"`\n\tFailcnt uint64 `json:\"failcnt\"`\n}\n```\nHugetlb holds information regarding a container huge tlb usage\n\n```go\ntype Memory struct {\n\tCache     uint64            `json:\"cache,omitempty\"`\n\tUsage     MemoryEntry       `json:\"usage,omitempty\"`\n\tSwap      MemoryEntry       `json:\"swap,omitempty\"`\n\tKernel    MemoryEntry       `json:\"kernel,omitempty\"`\n\tKernelTCP MemoryEntry       `json:\"kernelTCP,omitempty\"`\n\tRaw       map[string]uint64 `json:\"raw,omitempty\"`\n}\n```\nMemory holds information regarding the different type of memories available\n\n```go\ntype MemoryEntry struct {\n\tLimit   uint64 `json:\"limit\"`\n\tUsage   uint64 `json:\"usage,omitempty\"`\n\tMax     uint64 `json:\"max,omitempty\"`\n\tFailcnt uint64 `json:\"failcnt\"`\n}\n```\nMemoryEntry regroups statistic about a given type of memory\n\n```go\ntype OOM interface {\n\tio.Closer\n\tFD() int\n\tContainerID() string\n\tFlush()\n\tRemoved() bool\n}\n```\nOOM wraps a container OOM.\n\n```go\ntype Pids struct {\n\tCurrent uint64 `json:\"current,omitempty\"`\n\tLimit   uint64 `json:\"limit,omitempty\"`\n}\n```\nPids holds the stat of the pid usage of the machine\n\n```go\ntype PlatformProcessState struct {\n\tCheckpoint string `json:\"checkpoint\"`\n\tRootUID    int    `json:\"rootUID\"`\n\tRootGID    int    `json:\"rootGID\"`\n}\n```\nPlatformProcessState container platform-specific fields in the ProcessState structure\n\n```go\ntype Process interface {\n\tio.Closer\n\n\t// ID of the process.\n\t// This is either \"init\" when it is the container's init process or\n\t// it is a user provided id for the process similar to the container id\n\tID() string\n\t// Start unblocks the associated container init process.\n\t// This should only be called on the process with ID \"init\"\n\tStart() error\n\tCloseStdin() error\n\tResize(int, int) error\n\t// ExitFD returns the fd the provides an event when the process exits\n\tExitFD() int\n\t// ExitStatus returns the exit status of the process or an error if it\n\t// has not exited\n\tExitStatus() (uint32, error)\n\t// Spec returns the process spec that created the process\n\tSpec() specs.ProcessSpec\n\t// Signal sends the provided signal to the process\n\tSignal(os.Signal) error\n\t// Container returns the container that the process belongs to\n\tContainer() Container\n\t// Stdio of the container\n\tStdio() Stdio\n\t// SystemPid is the pid on the system\n\tSystemPid() int\n\t// State returns if the process is running or not\n\tState() State\n\t// Wait reaps the shim process if avaliable\n\tWait()\n}\n```\nProcess holds the operation allowed on a container's process\n\n```go\ntype ProcessState struct {\n\tspecs.ProcessSpec\n\tExec        bool     `json:\"exec\"`\n\tStdin       string   `json:\"containerdStdin\"`\n\tStdout      string   `json:\"containerdStdout\"`\n\tStderr      string   `json:\"containerdStderr\"`\n\tRuntimeArgs []string `json:\"runtimeArgs\"`\n\tNoPivotRoot bool     `json:\"noPivotRoot\"`\n\n\tPlatformProcessState\n}\n```\nProcessState holds the process OCI specs along with various fields required by containerd\n\n```go\ntype Resource struct {\n\tCPUShares         int64\n\tBlkioWeight       uint16\n\tCPUPeriod         int64\n\tCPUQuota          int64\n\tCpusetCpus        string\n\tCpusetMems        string\n\tKernelMemory      int64\n\tKernelTCPMemory   int64\n\tMemory            int64\n\tMemoryReservation int64\n\tMemorySwap        int64\n}\n```\nResource regroups the various container limits that can be updated\n\n```go\ntype Stat struct {\n\t// Timestamp is the time that the statistics where collected\n\tTimestamp time.Time\n\tCPU       CPU                `json:\"cpu\"`\n\tMemory    Memory             `json:\"memory\"`\n\tPids      Pids               `json:\"pids\"`\n\tBlkio     Blkio              `json:\"blkio\"`\n\tHugetlb   map[string]Hugetlb `json:\"hugetlb\"`\n}\n```\nStat holds a container statistics\n\n```go\ntype State string\n```\nState represents a container state\n\n```go\ntype Stdio struct {\n\tStdin  string\n\tStdout string\n\tStderr string\n}\n```\nStdio holds the path to the 3 pipes used for the standard ios.\n\n```go\nfunc NewStdio(stdin, stdout, stderr string) Stdio\n```\nNewStdio wraps the given standard io path into an Stdio struct. If a given parameter is the empty string, it is replaced by \"/dev/null\"\n\n```go\ntype Throttling struct {\n\tPeriods          uint64 `json:\"periods,omitempty\"`\n\tThrottledPeriods uint64 `json:\"throttledPeriods,omitempty\"`\n\tThrottledTime    uint64 `json:\"throttledTime,omitempty\"`\n}\n```\nThrottling holds a cpu throttling information\n\n","path":"github.com/docker/containerd/runtime","name":"runtime","synopsis":"","isRedistributable":true}
