github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/libcontainer/container.go (about)

     1  // Package libcontainer provides a native Go implementation for creating containers
     2  // with namespaces, cgroups, capabilities, and filesystem access controls.
     3  // It allows you to manage the lifecycle of the container performing additional operations
     4  // after the container is created.
     5  package libcontainer
     6  
     7  import (
     8  	"time"
     9  
    10  	"github.com/opencontainers/runc/libcontainer/configs"
    11  )
    12  
    13  // Status is the status of a container.
    14  type Status int
    15  
    16  const (
    17  	// Created is the status that denotes the container exists but has not been run yet.
    18  	Created Status = iota
    19  	// Running is the status that denotes the container exists and is running.
    20  	Running
    21  	// Paused is the status that denotes the container exists, but all its processes are paused.
    22  	Paused
    23  	// Stopped is the status that denotes the container does not have a created or running process.
    24  	Stopped
    25  )
    26  
    27  func (s Status) String() string {
    28  	switch s {
    29  	case Created:
    30  		return "created"
    31  	case Running:
    32  		return "running"
    33  	case Paused:
    34  		return "paused"
    35  	case Stopped:
    36  		return "stopped"
    37  	default:
    38  		return "unknown"
    39  	}
    40  }
    41  
    42  // BaseState represents the platform agnostic pieces relating to a
    43  // running container's state
    44  type BaseState struct {
    45  	// ID is the container ID.
    46  	ID string `json:"id"`
    47  
    48  	// InitProcessPid is the init process id in the parent namespace.
    49  	InitProcessPid int `json:"init_process_pid"`
    50  
    51  	// InitProcessStartTime is the init process start time in clock cycles since boot time.
    52  	InitProcessStartTime uint64 `json:"init_process_start"`
    53  
    54  	// Created is the unix timestamp for the creation time of the container in UTC
    55  	Created time.Time `json:"created"`
    56  
    57  	// Config is the container's configuration.
    58  	Config configs.Config `json:"config"`
    59  }