import "github.com/containerd/containerd"
client.go client_opts.go container.go container_checkpoint_opts.go container_opts.go container_opts_unix.go container_restore_opts.go containerstore.go diff.go events.go export.go grpc.go image.go image_store.go import.go install.go install_opts.go lease.go namespaces.go process.go pull.go services.go signals.go signals_unix.go snapshotter_default_linux.go snapshotter_opts_unix.go task.go task_opts.go task_opts_unix.go unpacker.go
const ( // DefaultSnapshotter will set the default snapshotter for the platform. // This will be based on the client compilation target, so take that into // account when choosing this value. DefaultSnapshotter = "overlayfs" )
const StopSignalLabel = "io.containerd.image.config.stop-signal"
StopSignalLabel is a well-known containerd label for storing the stop signal specified in the OCI image config
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.
var ( // ErrCheckpointRWUnsupported is returned if the container runtime does not support checkpoint ErrCheckpointRWUnsupported = errors.New("rw checkpoint is only supported on v2 runtimes") // ErrMediaTypeNotFound returns an error when a media type in the manifest is unknown ErrMediaTypeNotFound = errors.New("media type not found") )
var ( // ErrImageNameNotFoundInIndex is returned when the image name is not found in the index ErrImageNameNotFoundInIndex = errors.New("image name not found in index") // ErrRuntimeNameNotFoundInIndex is returned when the runtime is not found in the index ErrRuntimeNameNotFoundInIndex = errors.New("runtime not found in index") // ErrSnapshotterNameNotFoundInIndex is returned when the snapshotter is not found in the index ErrSnapshotterNameNotFoundInIndex = errors.New("snapshotter not found in index") )
CheckRuntime returns true if the current runtime matches the expected runtime. Providing various parts of the runtime schema will match those parts of the expected runtime
GetIndexByMediaType returns the index in a manifest for the specified media type
GetOCIStopSignal retrieves the stop signal specified in the OCI image config
func GetStopSignal(ctx context.Context, container Container, defaultSignal syscall.Signal) (syscall.Signal, error)
GetStopSignal retrieves the container stop signal, specified by the well-known containerd label (StopSignalLabel)
func NewImageStoreFromClient(client imagesapi.ImagesClient) images.Store
NewImageStoreFromClient returns a new image store client
func NewNamespaceStoreFromClient(client api.NamespacesClient) namespaces.Store
NewNamespaceStoreFromClient returns a new namespace store
func NewRemoteContainerStore(client containersapi.ContainersClient) containers.Store
NewRemoteContainerStore returns the container Store connected with the provided client
ParseSignal parses a given string into a syscall.Signal the rawSignal can be a string with "SIG" prefix, or a signal number in string format.
func WithCheckpointImage(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error
WithCheckpointImage includes the container image in the checkpoint
func WithCheckpointRW(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error
WithCheckpointRW includes the rw in the checkpoint
func WithCheckpointRuntime(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error
WithCheckpointRuntime includes the container runtime info
func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error
WithCheckpointTask includes the running task
func WithCheckpointTaskExit(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error
WithCheckpointTaskExit causes the task to exit after checkpoint
func WithInstallLibs(c *InstallConfig)
WithInstallLibs installs libs from the image
func WithInstallReplace(c *InstallConfig)
WithInstallReplace will replace existing files
WithKillAll kills all processes for a task
WithNoNewKeyring causes tasks not to be created with a new keyring for secret storage. There is an upper limit on the number of keyrings in a linux system
WithNoPivotRoot instructs the runtime not to you pivot_root
WithProcessKill will forcefully kill and delete a process
func WithPullUnpack(_ *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.
WithRemapperLabels creates the labels used by any supporting snapshotter to shift the filesystem ownership (user namespace mapping) automatically; currently supported by the fuse-overlayfs snapshotter
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.
WithSnapshotCleanup deletes the rootfs snapshot allocated for the container
func WithStdinCloser(r *IOCloseInfo)
WithStdinCloser closes the stdin of a process
func WithoutRefreshedMetadata(i *InfoConfig)
WithoutRefreshedMetadata will use the current metadata attached to the container object
type CheckpointOpts func(context.Context, *Client, *containers.Container, *imagespec.Index, *options.CheckpointOptions) error
CheckpointOpts are options to manage the checkpoint operation
type CheckpointTaskInfo struct { Name string // ParentCheckpoint is the digest of a parent checkpoint ParentCheckpoint digest.Digest // Options hold runtime specific settings for checkpointing a task Options interface{} // contains filtered or unexported fields }
CheckpointTaskInfo allows specific checkpoint information to be set for the task
func (i *CheckpointTaskInfo) Runtime() string
Runtime name for the container
type CheckpointTaskOpts func(*CheckpointTaskInfo) error
CheckpointTaskOpts allows the caller to set checkpoint options
func WithCheckpointImagePath(path string) CheckpointTaskOpts
WithCheckpointImagePath sets image path for checkpoint option
func WithCheckpointName(name string) CheckpointTaskOpts
WithCheckpointName sets the image name for the checkpoint
type Client struct {
// contains filtered or unexported fields
}
Client is the client to interact with containerd and its various services using a uniform interface
New returns a new containerd client that is connected to the containerd instance provided by address
NewWithConn returns a new containerd client that is connected to the containerd instance provided by the connection
Close closes the clients connection to containerd
func (c *Client) Conn() *grpc.ClientConn
Conn returns the underlying GRPC connection object
func (c *Client) ContainerService() containers.Store
ContainerService returns the underlying container Store
Containers returns all containers created in containerd
ContentStore returns the underlying content Store
func (c *Client) DiffService() DiffService
DiffService returns the underlying Differ
func (c *Client) EventService() EventService
EventService returns the underlying event service
Export exports images to a Tar stream. The tar archive is in OCI format with a Docker compatible manifest when a single target platform is given.
Fetch downloads the provided content into containerd's content store and returns a non-platform specific image reference
GetImage returns an existing image
GetLabel gets a label value from namespace store If there is no default label, an empty string returned with nil error
func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshotterName string) (platforms.MatchComparer, error)
func (c *Client) HealthService() grpc_health_v1.HealthClient
HealthService returns the underlying GRPC HealthClient
ImageService returns the underlying image Store
func (c *Client) Import(ctx context.Context, reader io.Reader, opts ...ImportOpt) ([]images.Image, error)
Import imports an image from a Tar stream using reader. Caller needs to specify importer. Future version may use oci.v1 as the default. Note that unreferenced blobs may be imported to the content store as well.
Install a binary image into the opt service
func (c *Client) IntrospectionService() introspection.Service
IntrospectionService returns the underlying Introspection Client
IsServing returns true if the client can successfully connect to the containerd daemon and the healthcheck service returns the SERVING response. This call will block if a transient error is encountered during connection. A timeout can be set in the context to ensure it returns early.
LeasesService returns the underlying Leases Client
ListImages returns all existing images
LoadContainer loads an existing container from metadata
func (c *Client) NamespaceService() namespaces.Store
NamespaceService returns the underlying Namespaces Store
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
Pull downloads the provided content into containerd's content store and returns a platform specific image object
func (c *Client) Push(ctx context.Context, ref string, desc ocispec.Descriptor, opts ...RemoteOpt) error
Push uploads the provided content to a remote resource
Reconnect re-establishes the GRPC connection to the containerd daemon
func (c *Client) Restore(ctx context.Context, id string, checkpoint Image, opts ...RestoreOpts) (Container, error)
Restore restores a container from a checkpoint
func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter
SnapshotService returns the underlying snapshotter for the provided snapshotter name
func (c *Client) Subscribe(ctx context.Context, filters ...string) (ch <-chan *events.Envelope, errs <-chan error)
Subscribe to events that match one or more of the provided filters.
Callers should listen on both the envelope and errs channels. If the errs channel returns nil or an error, the subscriber should terminate.
The subscriber can stop receiving events by canceling the provided context. The errs channel will be closed and return a nil error.
TaskService returns the underlying TasksClient
Version returns the version of containerd that the client is connected to
func (c *Client) VersionService() versionservice.VersionClient
VersionService returns the underlying VersionClient
func (c *Client) WithLease(ctx context.Context, opts ...leases.Opt) (context.Context, func(context.Context) error, error)
WithLease attaches a lease on the context
ClientOpt allows callers to set options on the containerd client
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 WithDefaultPlatform(platform platforms.MatchComparer) ClientOpt
WithDefaultPlatform sets the default platform matcher on the client
WithDefaultRuntime sets the default runtime on the client
func WithDialOpts(opts []grpc.DialOption) ClientOpt
WithDialOpts allows grpc.DialOptions to be set on the connection
func WithServices(opts ...ServicesOpt) ClientOpt
WithServices sets services used by the client.
WithTimeout sets the connection timeout for the client
type Container interface { // ID identifies the container ID() string // Info returns the underlying container record type Info(context.Context, ...InfoOpts) (containers.Container, error) // Delete removes the container Delete(context.Context, ...DeleteOpts) error // NewTask creates a new task based on the container metadata NewTask(context.Context, cio.Creator, ...NewTaskOpts) (Task, error) // Spec returns the OCI runtime specification Spec(context.Context) (*oci.Spec, error) // Task returns the current task for the container // // If cio.Attach 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 // // Clients must make sure that only one reader is attached to the task and consuming // the output from the task's fifos Task(context.Context, cio.Attach) (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) // Extensions returns the extensions set on the container Extensions(context.Context) (map[string]prototypes.Any, error) // Update a container Update(context.Context, ...UpdateContainerOpts) error // Checkpoint creates a checkpoint image of the current container Checkpoint(context.Context, string, ...CheckpointOpts) (Image, error) }
Container is a metadata object for container resources and task creation
DeleteOpts allows the caller to set options for the deletion of a container
DiffService handles the computation and application of diffs
func NewDiffServiceFromClient(client diffapi.DiffClient) DiffService
NewDiffServiceFromClient returns a new diff service which communicates over a GRPC connection.
EventService handles the publish, forward and subscribe of events.
func NewEventServiceFromClient(client eventsapi.EventsClient) EventService
NewEventServiceFromClient returns a new event service which communicates over a GRPC connection.
type ExitStatus struct {
// contains filtered or unexported fields
}
ExitStatus encapsulates a process's exit status. It is used by `Wait()` to return either a process exit code or an error
NewExitStatus populates an ExitStatus
func (s ExitStatus) Error() error
Error returns the error, if any, that occurred while waiting for the process.
func (s ExitStatus) ExitCode() uint32
ExitCode returns the exit code of the process. This is only valid is Error() returns nil
func (s ExitStatus) ExitTime() time.Time
ExitTime returns the exit time of the process This is only valid is Error() returns nil
Result returns the exit code and time of the exit status. An error may be returned here to which indicates there was an error
at some point while waiting for the exit status. It does not signify an error with the process itself.
If an error is returned, the process may still be running.
IOCloseInfo allows specific io pipes to be closed on a process
type IOCloserOpts func(*IOCloseInfo)
IOCloserOpts allows the caller to set specific pipes as closed on a process
type Image interface { // Name of the image Name() string // Target descriptor for the image content Target() ocispec.Descriptor // Labels of the image Labels() map[string]string // Unpack unpacks the image's content into a snapshot Unpack(context.Context, string, ...UnpackOpt) error // RootFS returns the unpacked diffids that make up images rootfs. RootFS(ctx context.Context) ([]digest.Digest, error) // Size returns the total size of the image's packed resources. Size(ctx context.Context) (int64, error) // Usage returns a usage calculation for the image. Usage(context.Context, ...UsageOpt) (int64, error) // Config descriptor for the image. Config(ctx context.Context) (ocispec.Descriptor, error) // IsUnpacked returns whether or not an image is unpacked. IsUnpacked(context.Context, string) (bool, error) // ContentStore provides a content store which contains image blob data ContentStore() content.Store // Metadata returns the underlying image metadata Metadata() images.Image }
Image describes an image used by containers
NewImage returns a client image object from the metadata image
NewImageWithPlatform returns a client image object from the metadata image
ImportOpt allows the caller to specify import specific options
WithAllPlatforms is used to import content for all platforms.
WithDigestRef is used to create digest images for each manifest in the index.
WithImageRefTranslator is used to translate the index reference to an image reference for the image store.
WithImportCompression compresses uncompressed layers on import. This is used for import formats which do not include the manifest.
WithIndexName creates a tag pointing to the imported index
type InfoConfig struct { // Refresh will to a fetch of the latest container metadata Refresh bool }
InfoConfig specifies how container metadata is fetched
type InfoOpts func(*InfoConfig)
InfoOpts controls how container metadata is fetched and returned
type InstallConfig struct { // Libs installs libs from the image Libs bool // Replace will overwrite existing binaries or libs in the opt directory Replace bool // Path to install libs and binaries to Path string }
InstallConfig sets the binary install configuration
type InstallOpts func(*InstallConfig)
InstallOpts configures binary installs
func WithInstallPath(path string) InstallOpts
WithInstallPath sets the optional install path
type KillInfo struct { // All kills all processes inside the task // only valid on tasks, ignored on processes All bool // ExecID is the ID of a process to kill ExecID string }
KillInfo contains information on how to process a Kill action
KillOpts allows options to be set for the killing of a process
WithKillExecID specifies the process ID
NewContainerOpts allows the caller to set additional options when creating a container
func WithAdditionalContainerLabels(labels map[string]string) NewContainerOpts
WithAdditionalContainerLabels adds the provided labels to the container The existing labels are preserved as long as they do not conflict with the added labels.
func WithContainerExtension(name string, extension interface{}) NewContainerOpts
WithContainerExtension appends extension data to the container object. Use this to decorate the container object with additional data for the client integration.
Make sure to register the type of `extension` in the typeurl package via `typeurl.Register` or container creation may fail.
func WithContainerLabels(labels map[string]string) NewContainerOpts
WithContainerLabels sets the provided labels to the container. The existing labels are cleared. Use WithAdditionalContainerLabels to preserve the existing labels.
func WithImage(i Image) NewContainerOpts
WithImage sets the provided image as the base for the container
func WithImageName(n string) NewContainerOpts
WithImageName allows setting the image name as the base for the container
func WithImageStopSignal(image Image, defaultSignal string) NewContainerOpts
WithImageStopSignal sets a well-known containerd label (StopSignalLabel) on the container for storing the stop signal specified in the OCI image config
WithNewSnapshot allocates a new snapshot to be used by the container as the root filesystem in read-write mode
WithNewSnapshotView allocates a new snapshot to be used by the container as the root filesystem in read-only mode
func WithNewSpec(opts ...oci.SpecOpts) NewContainerOpts
WithNewSpec generates a new spec for a new container
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 WithRemappedSnapshotView(id string, i Image, uid, gid uint32) NewContainerOpts
WithRemappedSnapshotView is similar to WithRemappedSnapshot but rootfs is mounted as read-only.
func WithRestoreImage(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts
WithRestoreImage restores the image for the container
func WithRestoreRW(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts
WithRestoreRW restores the rw layer from the checkpoint for the container
func WithRestoreRuntime(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts
WithRestoreRuntime restores the runtime for the container
func WithRestoreSpec(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts
WithRestoreSpec restores the spec from the checkpoint for the container
func WithRuntime(name string, options interface{}) 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(id string) NewContainerOpts
WithSnapshot uses an existing root filesystem for the container
func WithSnapshotter(name string) NewContainerOpts
WithSnapshotter sets the provided snapshotter for use by the container
This option must appear before other snapshotter options to have an effect.
WithSpec sets the provided spec on the container
NewTaskOpts allows the caller to set options on a new task
func WithGIDOwner(gid uint32) NewTaskOpts
WithGIDOwner allows console I/O to work with the remapped GID in user namespace
func WithRestoreImagePath(path string) NewTaskOpts
WithRestoreImagePath sets image path for create option
func WithRootFS(mounts []mount.Mount) NewTaskOpts
WithRootFS allows a task to be created without a snapshot being allocated to its container
func WithShimCgroup(path string) NewTaskOpts
WithShimCgroup sets the existing cgroup for the shim
func WithTaskCheckpoint(im Image) NewTaskOpts
WithTaskCheckpoint allows a task to be created with live runtime and memory data from a previous checkpoint. Additional software such as CRIU may be required to restore a task from a checkpoint
func WithUIDOwner(uid uint32) NewTaskOpts
WithUIDOwner allows console I/O to work with the remapped UID in user namespace
type Process interface { // ID of the process ID() string // 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) (*ExitStatus, error) // Kill sends the provided signal to the process Kill(context.Context, syscall.Signal, ...KillOpts) error // Wait asynchronously waits for the process to exit, and sends the exit code to the returned channel Wait(context.Context) (<-chan ExitStatus, error) // CloseIO allows various pipes to be closed on the process CloseIO(context.Context, ...IOCloserOpts) error // Resize changes the width and height of the process's terminal Resize(ctx context.Context, w, h uint32) error // IO returns the io set for the process IO() cio.IO // Status returns the executing status of the process Status(context.Context) (Status, error) }
Process represents a system process
ProcessDeleteOpts allows the caller to set options for the deletion of a task
type ProcessInfo struct { // Pid is the process ID Pid uint32 // Info includes additional process information // Info varies by platform Info *google_protobuf.Any }
ProcessInfo provides platform specific process information
ProcessStatus returns a human readable status for the Process representing its current status
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 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 // PlatformMatcher is used to match the platforms for an image // operation and define the preference when a single match is required // from multiple platforms. PlatformMatcher platforms.MatchComparer // Unpack is done after an image is pulled to extract into a snapshotter. // It is done simultaneously for schema 2 images when they are pulled. // If an image is not unpacked on pull, it can be unpacked any time // afterwards. Unpacking is required to run an image. Unpack bool // UnpackOpts handles options to the unpack call. UnpackOpts []UnpackOpt // Snapshotter used for unpacking Snapshotter string // SnapshotterOpts are additional options to be passed to a snapshotter during pull SnapshotterOpts []snapshots.Opt // Labels to be applied to the created image Labels map[string]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 // HandlerWrapper wraps the handler which gets sent to dispatch. // Unlike BaseHandlers, this can run before and after the built // in handlers, allowing operations to run on the descriptor // after it has completed transferring. HandlerWrapper func(images.Handler) 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 // Platforms defines which platforms to handle when doing the image operation. // Platforms is ignored when a PlatformMatcher is set, otherwise the // platforms will be used to create a PlatformMatcher with no ordering // preference. Platforms []string // MaxConcurrentDownloads is the max concurrent content downloads for each pull. MaxConcurrentDownloads int // AllMetadata downloads all manifests and known-configuration files AllMetadata bool // ChildLabelMap sets the labels used to reference child objects in the content // store. By default, all GC reference labels will be set for all fetched content. ChildLabelMap func(ocispec.Descriptor) []string }
RemoteContext is used to configure object resolutions and transfers with remote content stores and image providers.
type RemoteOpt func(*Client, *RemoteContext) error
RemoteOpt allows the caller to set distribution options for a remote
WithAllMetadata downloads all manifests and known-configuration files
func WithChildLabelMap(fn func(ocispec.Descriptor) []string) RemoteOpt
WithChildLabelMap sets the map function used to define the labels set on referenced child content in the content store. This can be used to overwrite the default GC labels or filter which labels get set for content. The default is `images.ChildGCLabels`.
WithImageHandler adds a base handler to be called on dispatch.
WithImageHandlerWrapper wraps the handlers to be called on dispatch.
WithMaxConcurrentDownloads sets max concurrent download limit.
WithPlatform allows the caller to specify a platform to retrieve content for
func WithPlatformMatcher(m platforms.MatchComparer) RemoteOpt
WithPlatformMatcher specifies the matcher to use for determining which platforms to pull content for. This value supersedes anything set with `WithPlatform`.
WithPullLabel sets a label to be associated with a pulled reference
WithPullLabels associates a set of labels to a pulled reference
WithPullSnapshotter specifies snapshotter name used for unpacking.
WithResolver specifies the resolver to use.
WithUnpackOpts is used to add unpack options to the unpacker.
RestoreOpts are options to manage the restore operation
type ServicesOpt func(c *services)
ServicesOpt allows callers to set options on the services
func WithContainerService(containerService containersapi.ContainersClient) ServicesOpt
WithContainerService sets the container service.
func WithContentStore(contentStore content.Store) ServicesOpt
WithContentStore sets the content store.
func WithDiffService(diffService diff.DiffClient) ServicesOpt
WithDiffService sets the diff service.
func WithEventService(eventService EventService) ServicesOpt
WithEventService sets the event service.
func WithImageService(imageService imagesapi.ImagesClient) ServicesOpt
WithImageService sets the image service.
func WithIntrospectionService(in introspectionapi.IntrospectionClient) ServicesOpt
WithIntrospectionService sets the introspection service.
func WithLeasesService(leasesService leases.Manager) ServicesOpt
WithLeasesService sets the lease service.
func WithNamespaceService(namespaceService namespacesapi.NamespacesClient) ServicesOpt
WithNamespaceService sets the namespace service.
func WithSnapshotters(snapshotters map[string]snapshots.Snapshotter) ServicesOpt
WithSnapshotters sets the snapshotters.
func WithTaskService(taskService tasks.TasksClient) ServicesOpt
WithTaskService sets the task service.
type Status struct { // Status of the process Status ProcessStatus // ExitStatus returned by the process ExitStatus uint32 // ExitedTime is the time at which the process died ExitTime time.Time }
Status returns process status and exit information
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, cio.Creator) (Process, error) // Pids returns a list of system specific process ids inside the task Pids(context.Context) ([]ProcessInfo, error) // Checkpoint serializes the runtime and memory information of a task into an // OCI Index that can be pushed and pulled from a remote resource. // // Additional software like CRIU maybe required to checkpoint and restore tasks // NOTE: Checkpoint supports to dump task information to a directory, in this way, // an empty OCI Index will be returned. Checkpoint(context.Context, ...CheckpointTaskOpts) (Image, error) // Update modifies executing tasks with updated settings Update(context.Context, ...UpdateTaskOpts) error // LoadProcess loads a previously created exec'd process LoadProcess(context.Context, string, cio.Attach) (Process, error) // Metrics returns task metrics for runtime specific metrics // // The metric types are generic to containerd and change depending on the runtime // For the built in Linux runtime, github.com/containerd/cgroups.Metrics // are returned in protobuf format Metrics(context.Context) (*types.Metric, error) // Spec returns the current OCI specification for the task Spec(context.Context) (*oci.Spec, error) }
Task is the executable object within containerd
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{} // contains filtered or unexported fields }
TaskInfo sets options for task creation
Runtime name for the container
type UnpackConfig struct { // ApplyOpts for applying a diff to a snapshotter ApplyOpts []diff.ApplyOpt // SnapshotOpts for configuring a snapshotter SnapshotOpts []snapshots.Opt // CheckPlatformSupported is whether to validate that a snapshotter // supports an image's platform before unpacking CheckPlatformSupported bool }
UnpackConfig provides configuration for the unpack of an image
type UnpackOpt func(context.Context, *UnpackConfig) error
UnpackOpt provides configuration for unpack
WithSnapshotterPlatformCheck sets `CheckPlatformSupported` on the UnpackConfig
UpdateContainerOpts allows the caller to set additional options when updating a container
type UpdateTaskInfo struct { // Resources updates a tasks resource constraints Resources interface{} // Annotations allows arbitrary and/or experimental resource constraints for task update Annotations map[string]string }
UpdateTaskInfo allows updated specific settings to be changed on a task
UpdateTaskOpts allows a caller to update task settings
func WithAnnotations(annotations map[string]string) UpdateTaskOpts
WithAnnotations sets the provided annotations for task updates.
func WithResources(resources interface{}) UpdateTaskOpts
WithResources sets the provided resources for task updates. Resources must be either a *specs.LinuxResources or a *specs.WindowsResources
UsageOpt is used to configure the usage calculation
WithManifestUsage is used to get the usage for an image based on what is reported by the manifests rather than what exists in the content store. NOTE: This function is best used with the manifest limit set to get a consistent value, otherwise non-existent manifests will be excluded.
WithSnapshotUsage will check for referenced snapshots from the image objects and include the snapshot size in the total usage.
WithUsageManifestLimit sets the limit to the number of manifests which will be walked for usage. Setting this value to 0 will require all manifests to be walked, returning ErrNotFound if manifests are missing. NOTE: By default all manifests which exist will be walked and any non-existent manifests and their subobjects will be ignored.
type Version struct { // Version number Version string // Revision from git that was built Revision string }
Version of containerd
Package containerd imports 82 packages (graph) and is imported by 376 packages. Updated 2021-01-23. Refresh now. Tools for package owners.