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

package containerd

import "github.com/containerd/containerd"

Index

Constants

const UnknownExitStatus = 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

func WithHostHosts

func WithHostHosts(s *specs.Spec) error

func WithHostLocaltime

func WithHostLocaltime(s *specs.Spec) error

func WithHostResoveconf

func WithHostResoveconf(s *specs.Spec) error

func WithNoNewPrivileges

func WithNoNewPrivileges(s *specs.Spec) error

WithNoNewPrivileges sets no_new_privileges on the process for the container

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)

func WithTTY

func WithTTY(s *specs.Spec) error

Types

type CheckpointTaskInfo

type CheckpointTaskInfo struct {
	ParentCheckpoint digest.Digest
	Options          interface{}
}

type CheckpointTaskOpts

type CheckpointTaskOpts func(*CheckpointTaskInfo) error

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)

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)

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)

func (*Client) Push

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

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)

func (*Client) VersionService

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

type ClientOpt

type ClientOpt func(c *clientOpts) error

func WithDefaultNamespace

func WithDefaultNamespace(ns string) ClientOpt

func WithDialOpts

func WithDialOpts(opts []grpc.DialOption) ClientOpt

WithDialOpts allows grpc.DialOptions to be set on the connection

type Container

type Container interface {
	ID() string
	Info() containers.Container
	Delete(context.Context, ...DeleteOpts) error
	NewTask(context.Context, IOCreation, ...NewTaskOpts) (Task, error)
	Spec() (*specs.Spec, error)
	Task(context.Context, IOAttach) (Task, error)
	Image(context.Context) (Image, error)
	Labels(context.Context) (map[string]string, error)
	SetLabels(context.Context, map[string]string) (map[string]string, error)
}

type DeleteOpts

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

type ExportOpt

type ExportOpt func(c *exportOpts) error

func WithOCIExportFormat

func WithOCIExportFormat() ExportOpt

type FIFOSet

type FIFOSet struct {
	// Dir is the directory holding the task fifos
	Dir          string
	In, Out, Err string
	Terminal     bool
}

func NewFifos

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

NewFifos returns a new set of fifos for the task

type IO

type IO struct {
	Terminal bool
	Stdin    string
	Stdout   string
	Stderr   string
	// contains filtered or unexported fields
}

func Stdio

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

Stdio returns an IO implementation 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()

func (*IO) Close

func (i *IO) Close() error

func (*IO) Wait

func (i *IO) Wait()

type IOAttach

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

func WithAttach

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

type IOCloseInfo

type IOCloseInfo struct {
	Stdin bool
}

type IOCloserOpts

type IOCloserOpts func(*IOCloseInfo)

type IOCreation

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

func NewIO

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

func NewIOWithTerminal

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

type Image

type Image interface {
	Name() string
	Target() ocispec.Descriptor

	Unpack(context.Context, string) error
}

type ImportOpt

type ImportOpt func(c *importOpts) error

func WithOCIImportFormat

func WithOCIImportFormat() ImportOpt

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

func WithCheckpoint

func WithCheckpoint(desc v1.Descriptor, rootfsID string) NewContainerOpts

func WithContainerLabels

func WithContainerLabels(labels map[string]string) NewContainerOpts

WithContainerLabels adds the provided labels to the container

func WithImage

func WithImage(i Image) NewContainerOpts

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 WithRemappedSnapshot

func WithRemappedSnapshot(id string, i Image, uid, gid uint32) NewContainerOpts

WithRemappedSnapshot creates a new snapshot and remaps the uid/gid for the filesystem to be used by a container with user namespaces

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

func WithSpec

func WithSpec(spec *specs.Spec) NewContainerOpts

WithSpec sets the provided spec for a new container

type NewTaskOpts

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

func WithRootFS

func WithRootFS(mounts []mount.Mount) NewTaskOpts

func WithTaskCheckpoint

func WithTaskCheckpoint(desc v1.Descriptor) NewTaskOpts

type Process

type Process interface {
	Pid() uint32
	Start(context.Context) error
	Delete(context.Context) (uint32, error)
	Kill(context.Context, syscall.Signal) error
	Wait(context.Context) (uint32, error)
	CloseIO(context.Context, ...IOCloserOpts) error
	Resize(ctx context.Context, w, h uint32) error
	IO() *IO
	Status(context.Context) (Status, error)
}

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

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 WithApparmorProfile

func WithApparmorProfile(profile string) SpecOpts

WithApparmor sets the provided apparmor profile to the spec

func WithHostNamespace

func WithHostNamespace(ns specs.LinuxNamespaceType) SpecOpts

func WithImageConfig

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

func WithLinuxNamespace

func WithLinuxNamespace(ns specs.LinuxNamespace) SpecOpts

WithLinuxNamespace uses the passed in namespace for the spec. If a namespace of the same type already exists in the spec, the existing namespace is replaced by the one provided.

func WithProcessArgs

func WithProcessArgs(args ...string) SpecOpts

WithProcessArgs replaces the args on the generated spec

func WithRootFSPath

func WithRootFSPath(path string, readonly bool) SpecOpts

WithRootFSPath specifies unmanaged rootfs path.

func WithUserNamespace

func WithUserNamespace(container, host, size uint32) SpecOpts

WithUserNamespace sets the uid and gid mappings for the task this can be called multiple times to add more mappings to the generated spec

type Status

type Status string
const (
	Running Status = "running"
	Created Status = "created"
	Stopped Status = "stopped"
	Paused  Status = "paused"
	Pausing Status = "pausing"
)

type Task

type TaskInfo

type TaskInfo struct {
	Checkpoint *types.Descriptor
	RootFS     []mount.Mount
	Options    interface{}
}

type UpdateTaskInfo

type UpdateTaskInfo struct {
	Resources interface{}
}

type UpdateTaskOpts

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

func WithResources

func WithResources(resources *specs.LinuxResources) UpdateTaskOpts

WithResources sets the provided resources on the spec for task updates

type Version

type Version struct {
	Version  string
	Revision string
}

Source Files

apparmor.go client.go client_unix.go container.go container_unix.go containerstore.go export.go grpc.go image.go import.go io.go io_unix.go process.go spec.go spec_unix.go task.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/containerd-shim
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
metrics
metrics/cgroups
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
reaper
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/btrfs
snapshot/naive
snapshot/overlay
snapshot/storagePackage storage provides a metadata storage implementation for snapshot drivers.
snapshot/storage/protoPackage proto is a generated protocol buffer package.
snapshot/testsuite
sysPackage sys provides access to the Get Child and Set Child prctl flags.
testutil
typeurl
version
windows
windows/hcsshimoptshcsshimopts holds the windows runtime specific options
Version
v1.0.0-alpha3
Published
Aug 2, 2017
Platform
linux/amd64
Imports
65 packages
Last checked
3 seconds ago

Tools for package owners.