gopkg.in/docker/docker.v23@v23.0.11/libcontainerd/types/types.go (about) 1 package types // import "github.com/docker/docker/libcontainerd/types" 2 3 import ( 4 "context" 5 "syscall" 6 "time" 7 8 "github.com/containerd/containerd" 9 "github.com/containerd/containerd/cio" 10 specs "github.com/opencontainers/runtime-spec/specs-go" 11 ) 12 13 // EventType represents a possible event from libcontainerd 14 type EventType string 15 16 // Event constants used when reporting events 17 const ( 18 EventUnknown EventType = "unknown" 19 EventExit EventType = "exit" 20 EventOOM EventType = "oom" 21 EventCreate EventType = "create" 22 EventStart EventType = "start" 23 EventExecAdded EventType = "exec-added" 24 EventExecStarted EventType = "exec-started" 25 EventPaused EventType = "paused" 26 EventResumed EventType = "resumed" 27 ) 28 29 // EventInfo contains the event info 30 type EventInfo struct { 31 ContainerID string 32 ProcessID string 33 Pid uint32 34 ExitCode uint32 35 ExitedAt time.Time 36 OOMKilled bool 37 Error error 38 } 39 40 // Backend defines callbacks that the client of the library needs to implement. 41 type Backend interface { 42 ProcessEvent(containerID string, event EventType, ei EventInfo) error 43 } 44 45 // Process of a container 46 type Process interface { 47 Delete(context.Context) (uint32, time.Time, error) 48 } 49 50 // Client provides access to containerd features. 51 type Client interface { 52 Version(ctx context.Context) (containerd.Version, error) 53 54 Restore(ctx context.Context, containerID string, attachStdio StdioCallback) (alive bool, pid int, p Process, err error) 55 56 Create(ctx context.Context, containerID string, spec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) error 57 Start(ctx context.Context, containerID, checkpointDir string, withStdin bool, attachStdio StdioCallback) (pid int, err error) 58 SignalProcess(ctx context.Context, containerID, processID string, signal syscall.Signal) error 59 Exec(ctx context.Context, containerID, processID string, spec *specs.Process, withStdin bool, attachStdio StdioCallback) (int, error) 60 ResizeTerminal(ctx context.Context, containerID, processID string, width, height int) error 61 CloseStdin(ctx context.Context, containerID, processID string) error 62 Pause(ctx context.Context, containerID string) error 63 Resume(ctx context.Context, containerID string) error 64 Stats(ctx context.Context, containerID string) (*Stats, error) 65 ListPids(ctx context.Context, containerID string) ([]uint32, error) 66 Summary(ctx context.Context, containerID string) ([]Summary, error) 67 DeleteTask(ctx context.Context, containerID string) (uint32, time.Time, error) 68 Delete(ctx context.Context, containerID string) error 69 Status(ctx context.Context, containerID string) (containerd.ProcessStatus, error) 70 71 UpdateResources(ctx context.Context, containerID string, resources *Resources) error 72 CreateCheckpoint(ctx context.Context, containerID, checkpointDir string, exit bool) error 73 } 74 75 // StdioCallback is called to connect a container or process stdio. 76 type StdioCallback func(io *cio.DirectIO) (cio.IO, error) 77 78 // InitProcessName is the name given to the first process of a container 79 const InitProcessName = "init"