containerd

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSocketPath = "/run/containerd/containerd.sock"
	DefaultNamespace  = "default"
)

Variables

View Source
var (
	ErrInvalidArgument = errors.New("invalid argument")
	ErrTaskStopTimeout = errors.New("timeout waiting for task to stop")
)

Functions

func MountSnapshot

func MountSnapshot(ctx context.Context, service Service, snapshotter, key string) (string, func() error, error)

MountSnapshot mounts a snapshot by snapshotter/key without a container.

func RemoveNetwork

func RemoveNetwork(ctx context.Context, task client.Task, containerID string) error

RemoveNetwork detaches CNI networking for a running task.

func ResolveConfSource

func ResolveConfSource(dataDir string) (string, error)

ResolveConfSource returns a host path to mount as /etc/resolv.conf. If systemd-resolved config is available, use it. Otherwise write a fallback resolv.conf under dataDir and return that path.

func SetupNetwork

func SetupNetwork(ctx context.Context, task client.Task, containerID string) error

SetupNetwork attaches CNI networking to a running task.

Types

type ClientFactory

type ClientFactory interface {
	New(ctx context.Context) (*containerd.Client, error)
}

type CreateContainerRequest

type CreateContainerRequest struct {
	ID          string
	ImageRef    string
	SnapshotID  string
	Snapshotter string
	Labels      map[string]string
	SpecOpts    []oci.SpecOpts
}

type DefaultClientFactory

type DefaultClientFactory struct {
	SocketPath string
}

func (DefaultClientFactory) New

type DefaultService

type DefaultService struct {
	// contains filtered or unexported fields
}

func NewDefaultService

func NewDefaultService(log *slog.Logger, client *containerd.Client, cfg config.Config) *DefaultService

func (*DefaultService) CommitSnapshot

func (s *DefaultService) CommitSnapshot(ctx context.Context, snapshotter, name, key string) error

func (*DefaultService) CreateContainer

func (*DefaultService) CreateContainerFromSnapshot

func (s *DefaultService) CreateContainerFromSnapshot(ctx context.Context, req CreateContainerRequest) (containerd.Container, error)

func (*DefaultService) DeleteContainer

func (s *DefaultService) DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error

func (*DefaultService) DeleteImage

func (s *DefaultService) DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error

func (*DefaultService) DeleteTask

func (s *DefaultService) DeleteTask(ctx context.Context, containerID string, opts *DeleteTaskOptions) error

func (*DefaultService) ExecTask

func (s *DefaultService) ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)

func (*DefaultService) ExecTaskStreaming

func (s *DefaultService) ExecTaskStreaming(ctx context.Context, containerID string, req ExecTaskRequest) (*ExecTaskSession, error)

func (*DefaultService) GetContainer

func (s *DefaultService) GetContainer(ctx context.Context, id string) (containerd.Container, error)

func (*DefaultService) GetImage

func (s *DefaultService) GetImage(ctx context.Context, ref string) (containerd.Image, error)

func (*DefaultService) GetTask

func (s *DefaultService) GetTask(ctx context.Context, containerID string) (containerd.Task, error)

func (*DefaultService) ListContainers

func (s *DefaultService) ListContainers(ctx context.Context) ([]containerd.Container, error)

func (*DefaultService) ListContainersByLabel

func (s *DefaultService) ListContainersByLabel(ctx context.Context, key, value string) ([]containerd.Container, error)

func (*DefaultService) ListImages

func (s *DefaultService) ListImages(ctx context.Context) ([]containerd.Image, error)

func (*DefaultService) ListSnapshots

func (s *DefaultService) ListSnapshots(ctx context.Context, snapshotter string) ([]snapshots.Info, error)

func (*DefaultService) ListTasks

func (s *DefaultService) ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)

func (*DefaultService) PrepareSnapshot

func (s *DefaultService) PrepareSnapshot(ctx context.Context, snapshotter, key, parent string) error

func (*DefaultService) PullImage

func (s *DefaultService) PullImage(ctx context.Context, ref string, opts *PullImageOptions) (containerd.Image, error)

func (*DefaultService) RemoveSnapshot

func (s *DefaultService) RemoveSnapshot(ctx context.Context, snapshotter, key string) error

func (*DefaultService) SnapshotMounts

func (s *DefaultService) SnapshotMounts(ctx context.Context, snapshotter, key string) ([]mount.Mount, error)

func (*DefaultService) StartTask

func (s *DefaultService) StartTask(ctx context.Context, containerID string, opts *StartTaskOptions) (containerd.Task, error)

func (*DefaultService) StopTask

func (s *DefaultService) StopTask(ctx context.Context, containerID string, opts *StopTaskOptions) error

type DeleteContainerOptions

type DeleteContainerOptions struct {
	CleanupSnapshot bool
}

type DeleteImageOptions

type DeleteImageOptions struct {
	Synchronous bool
}

type DeleteTaskOptions

type DeleteTaskOptions struct {
	Force bool
}

type ExecTaskRequest

type ExecTaskRequest struct {
	Args     []string
	Env      []string
	WorkDir  string
	Terminal bool
	UseStdio bool
	FIFODir  string
	Stdin    io.Reader
	Stdout   io.Writer
	Stderr   io.Writer
}

type ExecTaskResult

type ExecTaskResult struct {
	ExitCode uint32
}

type ExecTaskSession

type ExecTaskSession struct {
	Stdin  io.WriteCloser
	Stdout io.ReadCloser
	Stderr io.ReadCloser
	Wait   func() (ExecTaskResult, error)
	Close  func() error
}

type ListTasksOptions

type ListTasksOptions struct {
	Filter string
}

type MountedSnapshot

type MountedSnapshot struct {
	Dir     string
	Info    containers.Container
	Unmount func() error
}

func MountContainerSnapshot

func MountContainerSnapshot(ctx context.Context, service Service, containerID string) (*MountedSnapshot, error)

MountContainerSnapshot mounts the active snapshot for a container.

type PullImageOptions

type PullImageOptions struct {
	Unpack      bool
	Snapshotter string
}

type Service

type Service interface {
	PullImage(ctx context.Context, ref string, opts *PullImageOptions) (containerd.Image, error)
	GetImage(ctx context.Context, ref string) (containerd.Image, error)
	ListImages(ctx context.Context) ([]containerd.Image, error)
	DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error

	CreateContainer(ctx context.Context, req CreateContainerRequest) (containerd.Container, error)
	GetContainer(ctx context.Context, id string) (containerd.Container, error)
	ListContainers(ctx context.Context) ([]containerd.Container, error)
	DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error

	StartTask(ctx context.Context, containerID string, opts *StartTaskOptions) (containerd.Task, error)
	GetTask(ctx context.Context, containerID string) (containerd.Task, error)
	ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
	StopTask(ctx context.Context, containerID string, opts *StopTaskOptions) error
	DeleteTask(ctx context.Context, containerID string, opts *DeleteTaskOptions) error
	ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)
	ExecTaskStreaming(ctx context.Context, containerID string, req ExecTaskRequest) (*ExecTaskSession, error)
	ListContainersByLabel(ctx context.Context, key, value string) ([]containerd.Container, error)
	CommitSnapshot(ctx context.Context, snapshotter, name, key string) error
	ListSnapshots(ctx context.Context, snapshotter string) ([]snapshots.Info, error)
	RemoveSnapshot(ctx context.Context, snapshotter, key string) error
	PrepareSnapshot(ctx context.Context, snapshotter, key, parent string) error
	CreateContainerFromSnapshot(ctx context.Context, req CreateContainerRequest) (containerd.Container, error)
	SnapshotMounts(ctx context.Context, snapshotter, key string) ([]mount.Mount, error)
}

type SnapshotCommitResult

type SnapshotCommitResult struct {
	VersionSnapshotID string
	ActiveSnapshotID  string
}

type StartTaskOptions

type StartTaskOptions struct {
	UseStdio bool
	Terminal bool
	FIFODir  string
}

type StopTaskOptions

type StopTaskOptions struct {
	Signal  syscall.Signal
	Timeout time.Duration
	Force   bool
}

type TaskInfo

type TaskInfo struct {
	ContainerID string
	ID          string
	PID         uint32
	Status      tasktypes.Status
	ExitStatus  uint32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL