| // Package libcontainer provides a native Go implementation for creating containers |
| // with namespaces, cgroups, capabilities, and filesystem access controls. |
| // It allows you to manage the lifecycle of the container performing additional operations |
| // after the container is created. |
| package libcontainer |
| |
| import ( |
| "time" |
| |
| "github.com/opencontainers/runc/libcontainer/configs" |
| ) |
| |
| // Status is the status of a container. |
| type Status int |
| |
| const ( |
| // Created is the status that denotes the container exists but has not been run yet. |
| Created Status = iota |
| // Running is the status that denotes the container exists and is running. |
| Running |
| // Paused is the status that denotes the container exists, but all its processes are paused. |
| Paused |
| // Stopped is the status that denotes the container does not have a created or running process. |
| Stopped |
| ) |
| |
| func (s Status) String() string { |
| switch s { |
| case Created: |
| return "created" |
| case Running: |
| return "running" |
| case Paused: |
| return "paused" |
| case Stopped: |
| return "stopped" |
| default: |
| return "unknown" |
| } |
| } |
| |
| // BaseState represents the platform agnostic pieces relating to a |
| // running container's state |
| type BaseState struct { |
| // ID is the container ID. |
| ID string `json:"id"` |
| |
| // InitProcessPid is the init process id in the parent namespace. |
| InitProcessPid int `json:"init_process_pid"` |
| |
| // InitProcessStartTime is the init process start time in clock cycles since boot time. |
| InitProcessStartTime uint64 `json:"init_process_start"` |
| |
| // Created is the unix timestamp for the creation time of the container in UTC |
| Created time.Time `json:"created"` |
| |
| // Config is the container's configuration. |
| Config configs.Config `json:"config"` |
| } |