containerd – github.com/containerd/containerd Index | Files | Directories

package containerd

import "github.com/containerd/containerd"

Index

Constants

const UnknownExitStatus = 255

UnknownExitStatus is returned when containerd is unable to determine the exit status of a process. This can happen if the process never starts or if an error was encountered when obtaining the exit status, it is set to 255.

Functions

func GenerateSpec

func GenerateSpec(opts ...SpecOpts) (*specs.Spec, error)

GenerateSpec will generate a default spec from the provided image for use as a containerd container

func NewRemoteContainerStore

func NewRemoteContainerStore(client containersapi.ContainersClient) containers.Store

func WithExit

func WithExit(r *CheckpointTaskInfo) error

WithExit causes the task to exit after a successful checkpoint

func WithProcessKill

func WithProcessKill(ctx context.Context, p Process) error

WithProcessKill will forcefully kill and delete a process

func WithPullUnpack

func WithPullUnpack(client *Client, c *RemoteContext) error

WithPullUnpack is used to unpack an image after pull. This uses the snapshotter, content store, and diff service configured for the client.

func WithSchema1Conversion

func WithSchema1Conversion(client *Client, c *RemoteContext) error

WithSchema1Conversion is used to convert Docker registry schema 1 manifests to oci manifests on pull. Without this option schema 1 manifests will return a not supported error.

func WithSnapshotCleanup

func WithSnapshotCleanup(ctx context.Context, client *Client, c containers.Container) error

WithSnapshotCleanup deletes the rootfs allocated for the container

func WithStdinCloser

func WithStdinCloser(r *IOCloseInfo)

WithStdinCloser closes the stdin of a process

Types

type CheckpointTaskInfo

type CheckpointTaskInfo struct {
	// ParentCheckpoint is the digest of a parent checkpoint
	ParentCheckpoint digest.Digest
	// Options hold runtime specific settings for checkpointing a task
	Options interface{}
}

CheckpointTaskInfo allows specific checkpoint information to be set for the task

type CheckpointTaskOpts

type CheckpointTaskOpts func(*CheckpointTaskInfo) error

CheckpointTaskOpts allows the caller to set checkpoint options

type Client

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

Client is the client to interact with containerd and its various services using a uniform interface

func New

func New(address string, opts ...ClientOpt) (*Client, error)

New returns a new containerd client that is connected to the containerd instance provided by address

func NewWithConn

func NewWithConn(conn *grpc.ClientConn, opts ...ClientOpt) (*Client, error)

NewWithConn returns a new containerd client that is connected to the containerd instance provided by the connection

func (*Client) Close

func (c *Client) Close() error

Close closes the clients connection to containerd

func (*Client) ContainerService

func (c *Client) ContainerService() containers.Store

func (*Client) Containers

func (c *Client) Containers(ctx context.Context, filters ...string) ([]Container, error)

Containers returns all containers created in containerd

func (*Client) ContentStore

func (c *Client) ContentStore() content.Store

func (*Client) DiffService

func (c *Client) DiffService() diff.DiffService

func (*Client) EventService

func (c *Client) EventService() eventsapi.EventsClient

func (*Client) Export

func (c *Client) Export(ctx context.Context, desc ocispec.Descriptor, opts ...ExportOpt) (io.ReadCloser, error)

Export exports an image to a Tar stream. OCI format is used by default. It is up to caller to put "org.opencontainers.image.ref.name" annotation to desc.

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, ref string) (Image, error)

GetImage returns an existing image

func (*Client) HealthService

func (c *Client) HealthService() grpc_health_v1.HealthClient

func (*Client) ImageService

func (c *Client) ImageService() images.Store

func (*Client) Import

func (c *Client) Import(ctx context.Context, ref string, reader io.Reader, opts ...ImportOpt) (Image, error)

Import imports an image from a Tar stream using reader. OCI format is assumed by default.

Note that unreferenced blobs are imported to the content store as well.

func (*Client) IsServing

func (c *Client) IsServing(ctx context.Context) (bool, error)

IsServing returns true if the client can successfully connect to the containerd daemon and the healthcheck service returns the SERVING response

func (*Client) ListImages

func (c *Client) ListImages(ctx context.Context) ([]Image, error)

ListImages returns all existing images

func (*Client) LoadContainer

func (c *Client) LoadContainer(ctx context.Context, id string) (Container, error)

LoadContainer loads an existing container from metadata

func (*Client) NamespaceService

func (c *Client) NamespaceService() namespacesapi.NamespacesClient

func (*Client) NewContainer

func (c *Client) NewContainer(ctx context.Context, id string, opts ...NewContainerOpts) (Container, error)

NewContainer will create a new container in container with the provided id the id must be unique within the namespace

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpts) (Image, error)

Pull downloads the provided content into containerd's content store

func (*Client) Push

func (c *Client) Push(ctx context.Context, ref string, desc ocispec.Descriptor, opts ...RemoteOpts) error

Push uploads the provided content to a remote resource

func (*Client) SnapshotService

func (c *Client) SnapshotService(snapshotterName string) snapshot.Snapshotter

func (*Client) TaskService

func (c *Client) TaskService() tasks.TasksClient

func (*Client) Version

func (c *Client) Version(ctx context.Context) (Version, error)

Version returns the version of containerd that the client is connected to

func (*Client) VersionService

func (c *Client) VersionService() versionservice.VersionClient

type ClientOpt

type ClientOpt func(c *clientOpts) error

ClientOpt allows callers to set options on the containerd client

func WithDefaultNamespace

func WithDefaultNamespace(ns string) ClientOpt

WithDefaultNamespace sets the default namespace on the client

Any operation that does not have a namespace set on the context will be provided the default namespace

func WithDialOpts

func WithDialOpts(opts []grpc.DialOption) ClientOpt

WithDialOpts allows grpc.DialOptions to be set on the connection

type Container

type Container interface {
	// ID identifies the container
	ID() string
	// Info returns the underlying container record type
	Info() containers.Container
	// Delete removes the container
	Delete(context.Context, ...DeleteOpts) error
	// NewTask creates a new task based on the container metadata
	NewTask(context.Context, IOCreation, ...NewTaskOpts) (Task, error)
	// Spec returns the OCI runtime specification
	Spec() (*specs.Spec, error)
	// Task returns the current task for the container
	//
	// If IOAttach options are passed the client will reattach to the IO for the running
	// task. If no task exists for the container a NotFound error is returned
	Task(context.Context, IOAttach) (Task, error)
	// Image returns the image that the container is based on
	Image(context.Context) (Image, error)
	// Labels returns the labels set on the container
	Labels(context.Context) (map[string]string, error)
	// SetLabels sets the provided labels for the container and returns the final label set
	SetLabels(context.Context, map[string]string) (map[string]string, error)
}

Container is a metadata object for container resources and task creation

type DeleteOpts

type DeleteOpts func(context.Context, *Client, containers.Container) error

DeleteOpts allows the caller to set options for the deletion of a container

type ExportOpt

type ExportOpt func(c *exportOpts) error

ExportOpt allows callers to set export options

func WithOCIExportFormat

func WithOCIExportFormat() ExportOpt

WithOCIExportFormat sets the OCI image format as the export target

type FIFOSet

type FIFOSet struct {
	// Dir is the directory holding the task fifos
	Dir string
	// In, Out, and Err fifo paths
	In, Out, Err string
	// Terminal returns true if a terminal is being used for the task
	Terminal bool
}

FIFOSet is a set of fifos for use with tasks

func NewFifos

func NewFifos(id string) (*FIFOSet, error)

NewFifos returns a new set of fifos for the task

type IO

type IO struct {
	// Terminal is true if one has been allocated
	Terminal bool
	// Stdin path
	Stdin string
	// Stdout path
	Stdout string
	// Stderr path
	Stderr string
	// contains filtered or unexported fields
}

IO holds the io information for a task or process

func Stdio

func Stdio(id string) (*IO, error)

Stdio returns an IO set to be used for a task that outputs the container's IO as the current processes Stdio

func StdioTerminal

func StdioTerminal(id string) (*IO, error)

StdioTerminal will setup the IO for the task to use a terminal

func (*IO) Cancel

func (i *IO) Cancel()

Cancel aborts all current io operations

func (*IO) Close

func (i *IO) Close() error

Close cleans up all open io resources

func (*IO) Wait

func (i *IO) Wait()

Wait blocks until all io copy operations have completed

type IOAttach

type IOAttach func(*FIFOSet) (*IO, error)

IOAttach allows callers to reattach to running tasks

func WithAttach

func WithAttach(stdin io.Reader, stdout, stderr io.Writer) IOAttach

WithAttach attaches the existing io for a task to the provided io.Reader/Writers

type IOCloseInfo

type IOCloseInfo struct {
	Stdin bool
}

IOCloseInfo allows specific io pipes to be closed on a process

type IOCloserOpts

type IOCloserOpts func(*IOCloseInfo)

IOCloserOpts allows the caller to set specific pipes as closed on a process

type IOCreation

type IOCreation func(id string) (*IO, error)

IOCreation creates new IO sets for a task

func NewIO

func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation

NewIO returns an IOCreation that will provide IO sets without a terminal

func NewIOWithTerminal

func NewIOWithTerminal(stdin io.Reader, stdout, stderr io.Writer, terminal bool) IOCreation

NewIOWithTerminal creates a new io set with the provied io.Reader/Writers for use with a terminal

type Image

type Image interface {
	// Name of the image
	Name() string
	// Target descriptor for the image content
	Target() ocispec.Descriptor
	// Unpack unpacks the image's content into a snapshot
	Unpack(context.Context, string) error
}

Image describes an image used by containers

type ImportOpt

type ImportOpt func(c *importOpts) error

ImportOpt allows the caller to specify import specific options

func WithOCIImportFormat

func WithOCIImportFormat() ImportOpt

WithOCIImportFormat sets the import format for an OCI image format

func WithRefObject

func WithRefObject(refObject string) ImportOpt

WithRefObject specifies the ref object to import. If refObject is empty, it is copied from the ref argument of Import().

type NewContainerOpts

type NewContainerOpts func(ctx context.Context, client *Client, c *containers.Container) error

NewContainerOpts allows the caller to set additional options when creating a container

func WithContainerLabels

func WithContainerLabels(labels map[string]string) NewContainerOpts

WithContainerLabels adds the provided labels to the container

func WithImage

func WithImage(i Image) NewContainerOpts

WithImage sets the provided image as the base for the container

func WithNewSnapshot

func WithNewSnapshot(id string, i Image) NewContainerOpts

WithNewSnapshot allocates a new snapshot to be used by the container as the root filesystem in read-write mode

func WithNewSnapshotView

func WithNewSnapshotView(id string, i Image) NewContainerOpts

WithNewSnapshotView allocates a new snapshot to be used by the container as the root filesystem in read-only mode

func WithRuntime

func WithRuntime(name string) NewContainerOpts

WithRuntime allows a user to specify the runtime name and additional options that should be used to create tasks for the container

func WithSnapshot

func WithSnapshot(id string) NewContainerOpts

WithSnapshot uses an existing root filesystem for the container

func WithSnapshotter

func WithSnapshotter(name string) NewContainerOpts

WithSnapshotter sets the provided snapshotter for use by the container

func WithSpec

func WithSpec(spec *specs.Spec) NewContainerOpts

type NewTaskOpts

type NewTaskOpts func(context.Context, *Client, *TaskInfo) error

NewTaskOpts allows the caller to set options on a new task

func WithRootFS

func WithRootFS(mounts []mount.Mount) NewTaskOpts

WithRootFS allows a task to be created without a snapshot being allocated to its container

type Process

type Process interface {
	// Pid is the system specific process id
	Pid() uint32
	// Start starts the process executing the user's defined binary
	Start(context.Context) error
	// Delete removes the process and any resources allocated returning the exit status
	Delete(context.Context, ...ProcessDeleteOpts) (uint32, error)
	// Kill sends the provided signal to the process
	Kill(context.Context, syscall.Signal) error
	// Wait blocks until the process has exited returning the exit status
	Wait(context.Context) (uint32, error)
	// CloseIO allows various pipes to be closed on the process
	CloseIO(context.Context, ...IOCloserOpts) error
	// Resize changes the width and heigh of the process's terminal
	Resize(ctx context.Context, w, h uint32) error
	// IO returns the io set for the process
	IO() *IO
	// Status returns the executing status of the process
	Status(context.Context) (Status, error)
}

Process represents a system process

type ProcessDeleteOpts

type ProcessDeleteOpts func(context.Context, Process) error

ProcessDeleteOpts allows the caller to set options for the deletion of a task

type ProcessStatus

type ProcessStatus string
const (
	// Running indicates the process is currently executing
	Running ProcessStatus = "running"
	// Created indicates the process has been created within containerd but the
	// user's defined process has not started
	Created ProcessStatus = "created"
	// Stopped indicates that the process has ran and exited
	Stopped ProcessStatus = "stopped"
	// Paused indicates that the process is currently paused
	Paused ProcessStatus = "paused"
	// Pausing indicates that the process is currently switching from a
	// running state into a paused state
	Pausing ProcessStatus = "pausing"
	// Unknown indicates that we could not determine the status from the runtime
	Unknown ProcessStatus = "unknown"
)

type RemoteContext

type RemoteContext struct {
	// Resolver is used to resolve names to objects, fetchers, and pushers.
	// If no resolver is provided, defaults to Docker registry resolver.
	Resolver remotes.Resolver

	// Unpack is done after an image is pulled to extract into a snapshotter.
	// If an image is not unpacked on pull, it can be unpacked any time
	// afterwards. Unpacking is required to run an image.
	Unpack bool

	// Snapshotter used for unpacking
	Snapshotter string

	// BaseHandlers are a set of handlers which get are called on dispatch.
	// These handlers always get called before any operation specific
	// handlers.
	BaseHandlers []images.Handler

	// ConvertSchema1 is whether to convert Docker registry schema 1
	// manifests. If this option is false then any image which resolves
	// to schema 1 will return an error since schema 1 is not supported.
	ConvertSchema1 bool
}

RemoteContext is used to configure object resolutions and transfers with remote content stores and image providers.

type RemoteOpts

type RemoteOpts func(*Client, *RemoteContext) error

RemoteOpts allows the caller to set distribution options for a remote

func WithImageHandler

func WithImageHandler(h images.Handler) RemoteOpts

WithImageHandler adds a base handler to be called on dispatch.

func WithPullSnapshotter

func WithPullSnapshotter(snapshotterName string) RemoteOpts

WithPullSnapshotter specifies snapshotter name used for unpacking

func WithResolver

func WithResolver(resolver remotes.Resolver) RemoteOpts

WithResolver specifies the resolver to use.

type SpecOpts

type SpecOpts func(s *specs.Spec) error

SpecOpts sets spec specific information to a newly generated OCI spec

func WithHostname

func WithHostname(name string) SpecOpts

WithHostname sets the container's hostname

func WithImageConfig

func WithImageConfig(ctx context.Context, i Image) SpecOpts

func WithProcessArgs

func WithProcessArgs(args ...string) SpecOpts

WithProcessArgs replaces the args on the generated spec

func WithTTY

func WithTTY(width, height int) SpecOpts

type Status

type Status struct {
	// Status of the process
	Status ProcessStatus
	// ExitStatus returned by the process
	ExitStatus uint32
}

Status returns process status and exit information

type Task

type Task interface {
	Process

	// Pause suspends the execution of the task
	Pause(context.Context) error
	// Resume the execution of the task
	Resume(context.Context) error
	// Exec creates a new process inside the task
	Exec(context.Context, string, *specs.Process, IOCreation) (Process, error)
	// Pids returns a list of system specific process ids inside the task
	Pids(context.Context) ([]uint32, error)
	// Checkpoint serializes the runtime and memory information of a task into an
	// OCI Index that can be push and pulled from a remote resource.
	//
	// Additional software like CRIU maybe required to checkpoint and restore tasks
	Checkpoint(context.Context, ...CheckpointTaskOpts) (v1.Descriptor, error)
	// Update modifies executing tasks with updated settings
	Update(context.Context, ...UpdateTaskOpts) error
}

Task is the executable object within containerd

type TaskInfo

type TaskInfo struct {
	// Checkpoint is the Descriptor for an existing checkpoint that can be used
	// to restore a task's runtime and memory state
	Checkpoint *types.Descriptor
	// RootFS is a list of mounts to use as the task's root filesystem
	RootFS []mount.Mount
	// Options hold runtime specific settings for task creation
	Options interface{}
}

TaskInfo sets options for task creation

type UpdateTaskInfo

type UpdateTaskInfo struct {
	// Resources updates a tasks resource constraints
	Resources interface{}
}

UpdateTaskInfo allows updated specific settings to be changed on a task

type UpdateTaskOpts

type UpdateTaskOpts func(context.Context, *Client, *UpdateTaskInfo) error

UpdateTaskOpts allows a caller to update task settings

func WithResources

func WithResources(resources *specs.WindowsResources) UpdateTaskOpts

type Version

type Version struct {
	// Version number
	Version string
	// Revision from git that was built
	Revision string
}

Version of containerd

Source Files

client.go client_opts.go client_windows.go container.go container_opts.go containerstore.go export.go grpc.go image.go import.go io.go io_windows.go process.go spec.go spec_opts.go spec_opts_windows.go spec_windows.go task.go task_opts.go

Directories

PathSynopsis
api
api/services
api/services/containers
api/services/containers/v1Package containers is a generated protocol buffer package.
api/services/content
api/services/content/v1Package content is a generated protocol buffer package.
api/services/diff
api/services/diff/v1Package diff is a generated protocol buffer package.
api/services/events
api/services/events/v1Package events is a generated protocol buffer package.
api/services/images
api/services/images/v1Package images is a generated protocol buffer package.
api/services/namespaces
api/services/namespaces/v1Package namespaces is a generated protocol buffer package.
api/services/snapshot
api/services/snapshot/v1Package snapshot is a generated protocol buffer package.
api/services/tasks
api/services/tasks/v1Package tasks is a generated protocol buffer package.
api/services/version
api/services/version/v1Package version is a generated protocol buffer package.
api/typesPackage types is a generated protocol buffer package.
api/types/taskPackage task is a generated protocol buffer package.
archive
archive/compression
cmd
cmd/containerd
cmd/ctr
cmd/protoc-gen-gogoctrd
containers
content
content/local
content/testsuite
differ
errdefsPackage errdefs defines the common errors used throughout containerd packages.
events
filtersPackage filters defines a syntax and parser that can be used for the filtration of items across the containerd API.
fs
fs/fstest
gcPackage gc experiments with providing central gc tooling to ensure deterministic resource removal within containerd.
identifiersPackage identifiers provides common validation for identifiers and keys across containerd.
images
linux
linux/runcoptsPackage runcopts is a generated protocol buffer package.
linux/shim
linux/shim/v1Package shim is a generated protocol buffer package.
log
metadata
metadata/boltutil
mount
mount/lookup_test
namespacesPackage namespaces provides tools for working with namespaces across containerd.
ociPackage oci provides basic operations for manipulating OCI images.
plugin
progressPackage progress assists in displaying human readable progress information.
protobuf
protobuf/pluginPackage plugin is a generated protocol buffer package.
protobuf/plugin/fieldpath
reference
remotes
remotes/docker
remotes/docker/schema1
rootfs
runtime
server
services
services/containers
services/content
services/diff
services/events
services/healthcheck
services/images
services/namespaces
services/snapshot
services/tasks
services/version
snapshot
snapshot/naive
snapshot/storagePackage storage provides a metadata storage implementation for snapshot drivers.
snapshot/testsuite
snapshot/windows
sys
testutil
typeurl
version
windows
windows/hcsshimoptshcsshimopts holds the windows runtime specific options
Version
v1.0.0-alpha4
Published
Aug 10, 2017
Platform
windows/amd64
Imports
61 packages
Last checked
56 seconds ago

Tools for package owners.