Skip to content

Class: Containerd ​

The containerd component: manages the images, containers, CNI networks and volumes of one containerd namespace by talking to containerd's gRPC socket directly, without a Docker daemon and without nerdctl. Use it on the Linux machines running containerd alone (embedded devices, servers without Docker); the application needs access to the socket (root, or a member of the group owning it). Register it in the components of an application ({class: Containerd, ...}) and get it with getObject() or @Inject; it is a singleton.

Its API follows the Docker component's (pullImage, createContainer, container.exec()…). The containers it creates are nerdctl's: they carry nerdctl's labels (nerdctl/name…), so nerdctl ps lists them; containerd's shim writes their output to a log file and containerd's restart monitor applies their restart policy, also while the application is not running. The component pulls, pushes, imports and exports the images itself; it sends the builds to BuildKit (a local or remote buildkitd).

The component connects when it is created: it fails with ContainerdConnectionException when containerd does not answer on socketPath (or buildkitTLS is given with a unix socket), and it creates its namespace when the namespace does not exist. BuildKit is only reached by the builds. When the component is destroyed, it ends its event streams, aborts its pulls, pushes and builds in progress, and closes its connections.

Example ​

typescript
import {Application} from 'lakutata'
import {Containerd, type ContainerdContainer, type ContainerdExecResult, type ContainerdImage} from 'lakutata/com/containerd'

Application
    .run(() => ({
        id: 'device.app',
        name: 'Device',
        components: {
            containerd: {
                class: Containerd,
                socketPath: '/run/containerd/containerd.sock',
                namespace: 'default',
                registryAuths: {'registry.example.com': {username: 'deploy', password: 'secret'}}
            }
        },
        bootstrap: ['containerd']
    }))
    .onLaunched(async (app: Application): Promise<void> => {
        const containerd: Containerd = await app.getObject('containerd')
        //Pulled for the machine's platform, unpacked into the snapshotter
        const image: ContainerdImage = await containerd.pullImage({image: 'alpine:3.20'})
        const container: ContainerdContainer = await containerd.createContainer({
            image: image.name,
            name: 'worker',
            cmd: ['sleep', 'infinity'],
            //Restarted by containerd, even when the application is not running
            restartPolicy: 'always'
        })
        await container.start()
        const result: ContainerdExecResult = await container.exec({cmd: 'cat /etc/os-release'})
        console.log(result.exitCode, result.stdout)
    })

Extends ​

Constructors ​

Constructor ​

new Containerd(cradleProxy): Containerd

Called by the container only: an object is created through a container (see the class description), never with new.

Parameters ​

cradleProxy ​

Record<string | symbol, any>

The container's resolution proxy.

Returns ​

Containerd

Inherited from ​

Component.constructor

Properties ​

constructor ​

constructor: Function

The initial value of Object.prototype.constructor is the standard built-in Object constructor.

Inherited from ​

Component.constructor

Accessors ​

$id ​

Get Signature ​

get $id(): string | symbol

The name the object was registered under (its key in the module options), or a symbol of its class for an object registered by its class or built without registration.

Returns ​

string | symbol

Inherited from ​

Component.$id


$symbol ​

Get Signature ​

get $symbol(): symbol

A symbol unique to the instance (made from its $uuid), created on first read.

Returns ​

symbol

Inherited from ​

Component.$symbol


$uuid ​

Get Signature ​

get $uuid(): string

A random UUID identifying the instance.

Returns ​

string

Inherited from ​

Component.$uuid


className ​

Get Signature ​

get static className(): string

The name of the class.

Returns ​

string

Inherited from ​

Component.className


className ​

Get Signature ​

get className(): string

The name of the object's class.

Returns ​

string

Inherited from ​

Component.className

Methods ​

[asyncDispose]() ​

[asyncDispose](): Promise<void>

Dispose the object at the end of an await using block, as BaseObject.dispose.

Returns ​

Promise<void>

Resolves once the object is destroyed.

Inherited from ​

Component.[asyncDispose]


acceptsOption() ​

static acceptsOption(name, value): boolean

Whether the class accepts an option which is not one of its @Configurable properties (an option it reads with getConfigurableRecords()): the modules check the options of the objects they declare and warn of the options the classes do not accept. Override it in the classes reading options without configurable properties.

Parameters ​

name ​

string

The option name.

value ​

unknown

The option value.

Returns ​

boolean

true when the option is accepted; false by default.

Inherited from ​

Component.acceptsOption


addListener() ​

addListener(event, listener): this

Add a listener called synchronously, at the emitting, after the event's other listeners. Unlike on(), its listener runs before emit() returns.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

listener ​

ListenerFn

The function called with the event's values.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.addListener


assign() ​

Call Signature ​

static assign<T, U>(target, source): T & U

Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

Type Parameters ​
T ​

T extends object

U ​

U

Parameters ​
target ​

T

The target object to copy to.

source ​

U

The source object from which to copy properties.

Returns ​

T & U

Inherited from ​

Component.assign

Call Signature ​

static assign<T, U, V>(target, source1, source2): T & U & V

Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

Type Parameters ​
T ​

T extends object

U ​

U

V ​

V

Parameters ​
target ​

T

The target object to copy to.

source1 ​

U

The first source object from which to copy properties.

source2 ​

V

The second source object from which to copy properties.

Returns ​

T & U & V

Inherited from ​

Component.assign

Call Signature ​

static assign<T, U, V, W>(target, source1, source2, source3): T & U & V & W

Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

Type Parameters ​
T ​

T extends object

U ​

U

V ​

V

W ​

W

Parameters ​
target ​

T

The target object to copy to.

source1 ​

U

The first source object from which to copy properties.

source2 ​

V

The second source object from which to copy properties.

source3 ​

W

The third source object from which to copy properties.

Returns ​

T & U & V & W

Inherited from ​

Component.assign

Call Signature ​

static assign(target, ...sources): any

Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

Parameters ​
target ​

object

The target object to copy to.

sources ​

...any[]

One or more source objects from which to copy properties

Returns ​

any

Inherited from ​

Component.assign


buildImage() ​

buildImage(options): Promise<ContainerdImage>

Build an image with BuildKit (the local or remote daemon at buildkitAddress), as docker buildx build does: the build context (without the files its .dockerignore excludes) and the Dockerfile are sent over a BuildKit session, then the image built is imported into containerd, named by repoTag, and pushed when push is set. The base images are pulled by BuildKit with the component's registry credentials (or auth). The build is aborted when the component is destroyed.

Parameters ​

options ​

ImageBuildOptions

The context directory, the Dockerfile, the name, the platforms (the machine's by default), the build arguments, labels and target, nocache, pull, push, the credentials and the output callback.

Returns ​

Promise<ContainerdImage>

The image built.

Throws ​

BuildKit cannot be reached, the build fails, or its import fails.

Throws ​

With push, the push fails; the image is built and imported.


buildkitPlatforms() ​

buildkitPlatforms(): Promise<string[]>

List the platforms the BuildKit daemon builds for: the ones of its workers, including the emulators of its own machine.

Returns ​

Promise<string[]>

The platforms, formatted os/architecture[/variant].

Throws ​

BuildKit cannot be reached.


buildkitVersion() ​

buildkitVersion(): Promise<{ package: string; revision: string; version: string; }>

Get the version of the BuildKit daemon at buildkitAddress.

Returns ​

Promise<{ package: string; revision: string; version: string; }>

Its package (github.com/moby/buildkit), version and revision.

Throws ​

BuildKit cannot be reached.


create() ​

Call Signature ​

static create(o): any

Creates an object that has the specified prototype or that has null prototype.

Parameters ​
o ​

object | null

Object to use as a prototype. May be null.

Returns ​

any

Inherited from ​

Component.create

Call Signature ​

static create(o, properties): any

Creates an object that has the specified prototype, and that optionally contains specified properties.

Parameters ​
o ​

object | null

Object to use as a prototype. May be null

properties ​

PropertyDescriptorMap & ThisType<any>

JavaScript object that contains one or more property descriptors.

Returns ​

any

Inherited from ​

Component.create


createContainer() ​

createContainer(options): Promise<ContainerdContainer>

Create a container of an image present in containerd (it is not pulled): its snapshot, its OCI specification and its state directory (log file, hosts, resolv.conf, hostname). The container is not started. It joins the default CNI network bridge by default (created when first used, the CNI plugins needed), as with Docker; network: 'host' gives it the host's network. Its ports are published on its first CNI network. Its system calls are filtered by containerd's default seccomp profile, unless it is privileged or seccompProfile says otherwise. The settings are kept so that ContainerdContainer.update can create it again.

Parameters ​

options ​

ContainerCreateOptions

The image and the container's settings (name, command, environment, user, mounts, devices, networks, ports, resources, restart policy…).

Returns ​

Promise<ContainerdContainer>

The container created.

Throws ​

The image does not exist.

Throws ​

The image has no manifest for the platform asked (the machine's by default).

Throws ​

Another container has the name.

Throws ​

One of the CNI networks does not exist.

Throws ​

The settings cannot be applied: ports without a CNI network, no command, no CNI plugin installed, a device or a seccomp profile file that cannot be read.


createNetwork() ​

createNetwork(options): Promise<ContainerdNetworkInfo>

Create a CNI network as nerdctl network create does: its configuration nerdctl-<name>.conflist written in cniConfigPath, so nerdctl sees it. Its bridge and firewall rules are set up when the first container joins it.

Parameters ​

options ​

NetworkCreateOptions

Its name, driver (bridge, macvlan, ipvlan), IPv4 subnet (a free one of 10.4.0.0/16 by default), gateway and range, IPv6 subnet, parent interface, internal, MTU and labels.

Returns ​

Promise<ContainerdNetworkInfo>

The network created.

Throws ​

The name is taken (host, none and bridge included), or the subnet overlaps another network's.


createVolume() ​

createVolume(options): Promise<ContainerdVolumeInfo>

Create a named volume: a directory under dataRoot that containers mount by name. As Docker does, a volume that exists is returned unchanged (its labels are not updated). A container mounting a missing volume creates it too.

Parameters ​

options ​

VolumeCreateOptions

The name (letters, digits, _, . and -) and the labels.

Returns ​

Promise<ContainerdVolumeInfo>

The volume.


defineProperties() ​

static defineProperties<T>(o, properties): T

Adds one or more properties to an object, and/or modifies attributes of existing properties.

Type Parameters ​

T ​

T

Parameters ​

o ​

T

Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.

properties ​

PropertyDescriptorMap & ThisType<any>

JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.

Returns ​

T

Inherited from ​

Component.defineProperties


defineProperty() ​

static defineProperty<T>(o, p, attributes): T

Adds a property to an object, or modifies attributes of an existing property.

Type Parameters ​

T ​

T

Parameters ​

o ​

T

Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.

p ​

PropertyKey

The property name.

attributes ​

PropertyDescriptor & ThisType<any>

Descriptor for the property. It can be for a data property or an accessor property.

Returns ​

T

Inherited from ​

Component.defineProperty


detectPlatforms() ​

detectPlatforms(): string[]

Detect again the platforms this machine runs, after emulators were registered or removed in binfmt_misc.

Returns ​

string[]

The platforms detected, as Containerd.supportedPlatforms returns them from now on.


dispose() ​

dispose(): Promise<void>

Destroy the object: its beforeDestroy(), the objects it created, then its destroy(). Calling it more than once destroys once. A disposed singleton or scoped object is dropped from its container, which creates a new one on the next request. Using a destroyed object (getObject(), buildObject()) throws an ObjectDestroyedException.

Returns ​

Promise<void>

Resolves once the object is destroyed.

Throws ​

The error of the object's own beforeDestroy() or destroy() (an AggregateError when several fail); the errors of the objects it created are reported through the application's logger instead.

Inherited from ​

Component.dispose


emit() ​

emit(event, ...values): boolean

Emit an event: the listeners added by addListener() and onAny() are called now, in order; the ones added by on(), once(), many() and their prepended forms are scheduled (an error they throw is an unhandled rejection). Use emitRequest() to wait for the listeners and their results.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

values ​

...any[]

The values passed to the listeners.

Returns ​

boolean

true when the event has listeners.

Throws ​

The error emitted as an 'error' event which has no listener.

Inherited from ​

Component.emit


emitRequest() ​

emitRequest(event, ...values): Promise<any[]>

Emit an event and wait for its listeners (the asynchronous ones included).

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

values ​

...any[]

The values passed to the listeners.

Returns ​

Promise<any[]>

The results of the listeners, in their order (an empty array without listener).

Throws ​

The first error thrown by a listener, or the error emitted as an 'error' event which has no listener.

Inherited from ​

Component.emitRequest


entries() ​

Call Signature ​

static entries<T>(o): [string, T][]

Returns an array of key/values of the enumerable own properties of an object

Type Parameters ​
T ​

T

Parameters ​
o ​

{[s: string]: T; } | ArrayLike<T>

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

[string, T][]

Inherited from ​

Component.entries

Call Signature ​

static entries(o): [string, any][]

Returns an array of key/values of the enumerable own properties of an object

Parameters ​
o ​

{ }

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

[string, any][]

Inherited from ​

Component.entries


eventNames() ​

eventNames(nsAsArray?): (string | symbol | event[])[]

The events having listeners, in no guaranteed order.

Parameters ​

nsAsArray? ​

boolean

Return each namespaced event as the array of its parts (['order', 'paid']) instead of its name ('order.paid'); false by default.

Returns ​

(string | symbol | event[])[]

The events.

Inherited from ​

Component.eventNames


events() ​

events(signal?): AsyncGenerator<ContainerdEvent>

Stream containerd's events in the component's namespace (/tasks/exit, /containers/create, /images/delete…) as they happen. The stream ends without an error when signal aborts or when the component is destroyed. The fields of the task, container, image and snapshot events are decoded; the other events have an empty event.

Parameters ​

signal? ​

AbortSignal

Ends the stream when aborted; without it, the stream lasts as long as the component.

Returns ​

AsyncGenerator<ContainerdEvent>

The events, in their order.

Throws ​

The connection to containerd fails or is lost (from @lakutata/grpc).


exportImages() ​

exportImages(names, options): Promise<void>

Export images into one archive: an OCI image layout with the manifest.json of docker load, loaded by docker load, nerdctl load and Containerd.importImage. The archive has the platforms each image has in containerd.

Parameters ​

names ​

string[]

The names or references of the images (one at least).

options ​

ImageExportOptions

The destination: a file path (created or replaced) or a writable stream.

Returns ​

Promise<void>

Throws ​

One of the images does not exist.

Throws ​

The archive cannot be written.


freeze() ​

Call Signature ​

static freeze<T>(f): T

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Type Parameters ​
T ​

T extends Function

Parameters ​
f ​

T

Object on which to lock the attributes.

Returns ​

T

Inherited from ​

Component.freeze

Call Signature ​

static freeze<T, U>(o): Readonly<T>

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Type Parameters ​
T ​

T extends object

U ​

U extends string | number | bigint | boolean | symbol

Parameters ​
o ​

T

Object on which to lock the attributes.

Returns ​

Readonly<T>

Inherited from ​

Component.freeze

Call Signature ​

static freeze<T>(o): Readonly<T>

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Type Parameters ​
T ​

T

Parameters ​
o ​

T

Object on which to lock the attributes.

Returns ​

Readonly<T>

Inherited from ​

Component.freeze


fromEntries() ​

Call Signature ​

static fromEntries<T>(entries): object

Returns an object created by key-value entries for properties and methods

Type Parameters ​
T ​

T = any

Parameters ​
entries ​

Iterable<readonly [PropertyKey, T]>

An iterable object that contains key-value entries for properties and methods.

Returns ​

object

Inherited from ​

Component.fromEntries

Call Signature ​

static fromEntries(entries): any

Returns an object created by key-value entries for properties and methods

Parameters ​
entries ​

Iterable<readonly any[]>

An iterable object that contains key-value entries for properties and methods.

Returns ​

any

Inherited from ​

Component.fromEntries


getContainer() ​

getContainer(idOrName): Promise<ContainerdContainer>

Get a container.

Parameters ​

idOrName ​

string

Its identifier, its name, or a prefix of its identifier (3 hexadecimal characters at least).

Returns ​

Promise<ContainerdContainer>

The container, its information read from containerd.

Throws ​

No container matches.

Throws ​

The prefix matches several containers.


getImage() ​

getImage(name): Promise<ContainerdImage>

Get an image present in containerd; it is not pulled. The image is described for the first platform it has among Containerd.supportedPlatforms, or for the first platform it has.

Parameters ​

name ​

string

Its name or a reference, normalized as Docker does (alpine is docker.io/library/alpine:latest).

Returns ​

Promise<ContainerdImage>

The image.

Throws ​

No image has this name.

Throws ​

The content of none of its platforms is present.


getMaxListeners() ​

getMaxListeners(): number

The number of listeners of one event above which a possible memory leak is warned of.

Returns ​

number

The number, 0 for no warning.

Inherited from ​

Component.getMaxListeners


getMethod() ​

getMethod(name, throwExceptionIfNotFound?): (...args) => any

Get a method bound to the object, to call it by name.

Parameters ​

name ​

string | symbol

The method name or symbol.

throwExceptionIfNotFound? ​

boolean

Throw when the method does not exist, instead of returning a function doing nothing; false by default.

Returns ​

The bound method, or a function doing nothing (returning undefined) when it does not exist.

(...args) => any

Throws ​

When the method does not exist and throwExceptionIfNotFound is true.

Inherited from ​

Component.getMethod


getNetwork() ​

getNetwork(nameOrId): Promise<ContainerdNetworkInfo>

Get a network. Asking for bridge creates nerdctl's default network when it does not exist.

Parameters ​

nameOrId ​

string

Its name, its identifier, or a prefix of its identifier (3 characters at least).

Returns ​

Promise<ContainerdNetworkInfo>

The network.

Throws ​

No network matches.


getOwnPropertyDescriptor() ​

static getOwnPropertyDescriptor(o, p): PropertyDescriptor | undefined

Gets the own property descriptor of the specified object. An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.

Parameters ​

o ​

any

Object that contains the property.

p ​

PropertyKey

Name of the property.

Returns ​

PropertyDescriptor | undefined

Inherited from ​

Component.getOwnPropertyDescriptor


getOwnPropertyDescriptors() ​

static getOwnPropertyDescriptors<T>(o): { [P in string | number | symbol]: TypedPropertyDescriptor<T[P]> } & object

Returns an object containing all own property descriptors of an object

Type Parameters ​

T ​

T

Parameters ​

o ​

T

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

{ [P in string | number | symbol]: TypedPropertyDescriptor<T[P]> } & object

Inherited from ​

Component.getOwnPropertyDescriptors


getOwnPropertyNames() ​

static getOwnPropertyNames(o): string[]

Returns the names of the own properties of an object. The own properties of an object are those that are defined directly on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions.

Parameters ​

o ​

any

Object that contains the own properties.

Returns ​

string[]

Inherited from ​

Component.getOwnPropertyNames


getOwnPropertySymbols() ​

static getOwnPropertySymbols(o): symbol[]

Returns an array of all symbol properties found directly on object o.

Parameters ​

o ​

any

Object to retrieve the symbols from.

Returns ​

symbol[]

Inherited from ​

Component.getOwnPropertySymbols


getProperty() ​

getProperty<T>(propertyKey, defaultValue?): T

Read an own property of the object.

Type Parameters ​

T ​

T = any

Parameters ​

propertyKey ​

string

The property name.

defaultValue? ​

T

The value returned when the object has no own property of this name.

Returns ​

T

The property value, or the default value.

Inherited from ​

Component.getProperty


getPrototypeOf() ​

static getPrototypeOf(o): any

Returns the prototype of an object.

Parameters ​

o ​

any

The object that references the prototype.

Returns ​

any

Inherited from ​

Component.getPrototypeOf


getVolume() ​

getVolume(name): Promise<ContainerdVolumeInfo>

Get a named volume.

Parameters ​

name ​

string

The volume's name.

Returns ​

Promise<ContainerdVolumeInfo>

The volume: its host directory (mountpoint), labels and creation time.

Throws ​

The volume does not exist, or the name is not a valid one.


hasListeners() ​

hasListeners(event?): boolean

Whether an event has listeners (the wildcard listeners matching it included; the listeners of onAny() excluded).

Parameters ​

event? ​

string | symbol | event[]

The event name, its parts as an array, or a symbol; any event when omitted.

Returns ​

boolean

true when there are listeners.

Inherited from ​

Component.hasListeners


hasMethod() ​

hasMethod(name): boolean

Whether the object has a method of this name or symbol (a function of its class, not an own property).

Parameters ​

name ​

string | symbol

The method name or symbol.

Returns ​

boolean

true when the method exists.

Inherited from ​

Component.hasMethod


hasOwn() ​

static hasOwn(o, v): boolean

Determines whether an object has a property with the specified name.

Parameters ​

o ​

object

An object.

v ​

PropertyKey

A property name.

Returns ​

boolean

Inherited from ​

Component.hasOwn


hasOwnProperty() ​

hasOwnProperty(v): boolean

Determines whether an object has a property with the specified name.

Parameters ​

v ​

PropertyKey

A property name.

Returns ​

boolean

Inherited from ​

Component.hasOwnProperty


hasProperty() ​

hasProperty(propertyKey): boolean

Whether the object has an own property (not a method or accessor of its class) of this name or symbol.

Parameters ​

propertyKey ​

string | symbol

The property name or symbol.

Returns ​

boolean

true when the property exists.

Inherited from ​

Component.hasProperty


importImage() ​

importImage(options): Promise<ContainerdImage[]>

Import the images of an archive: an OCI image layout (nerdctl save, docker save of Docker 25+, the archives of Containerd.exportImages) or an older docker save archive. The images are named as the archive names them (or by name, for an archive of one image), replace the images of the same names, and the platforms the machine runs (Containerd.supportedPlatforms) are unpacked unless unpack: false. The images of an OCI layout without a name annotation are not imported unless name is given.

Parameters ​

options ​

ImageImportOptions

The archive (a file path or a readable stream), the name to give, and unpack.

Returns ​

Promise<ContainerdImage[]>

The images imported.

Throws ​

The archive cannot be read or is not an image archive; name is given with an archive of several images (nothing is imported); the unpacking fails (the images are stored and named).


is() ​

static is(value1, value2): boolean

Returns true if the values are the same value, false otherwise.

Parameters ​

value1 ​

any

The first value.

value2 ​

any

The second value.

Returns ​

boolean

Inherited from ​

Component.is


isExtensible() ​

static isExtensible(o): boolean

Returns a value that indicates whether new properties can be added to an object.

Parameters ​

o ​

any

Object to test.

Returns ​

boolean

Inherited from ​

Component.isExtensible


isFrozen() ​

static isFrozen(o): boolean

Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object.

Parameters ​

o ​

any

Object to test.

Returns ​

boolean

Inherited from ​

Component.isFrozen


isPrototypeOf() ​

isPrototypeOf(v): boolean

Determines whether an object exists in another object's prototype chain.

Parameters ​

v ​

Object

Another object whose prototype chain is to be checked.

Returns ​

boolean

Inherited from ​

Component.isPrototypeOf


isSealed() ​

static isSealed(o): boolean

Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.

Parameters ​

o ​

any

Object to test.

Returns ​

boolean

Inherited from ​

Component.isSealed


keys() ​

Call Signature ​

static keys(o): string[]

Returns the names of the enumerable string properties and methods of an object.

Parameters ​
o ​

object

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

string[]

Inherited from ​

Component.keys

Call Signature ​

static keys(o): string[]

Returns the names of the enumerable string properties and methods of an object.

Parameters ​
o ​

{ }

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

string[]

Inherited from ​

Component.keys


listContainers() ​

listContainers(labels?): Promise<ContainerdContainer[]>

List the containers of the namespace, running or not, the ones created by nerdctl included.

Parameters ​

labels? ​

Record<string, string>

Only the containers having all these labels with these values ({app: 'web'}); all of them by default.

Returns ​

Promise<ContainerdContainer[]>

The containers.


listenerCount() ​

listenerCount(event?): number

The number of listeners of an event (the wildcard listeners matching it included), or of every event (the listeners of onAny() excluded).

Parameters ​

event? ​

string | symbol | event[]

The event name or its parts as an array; every event when omitted.

Returns ​

number

The number of listeners.

Inherited from ​

Component.listenerCount


listeners() ​

listeners(event?): ListenerFn[]

The listeners of an event, or of every event.

Parameters ​

event? ​

string | symbol | event[]

The event name (the wildcard listeners matching it included), its parts as an array, or a symbol; every event when omitted (the listeners of onAny() excluded).

Returns ​

ListenerFn[]

A copy of the listeners; changing it does not change the listeners.

Inherited from ​

Component.listeners


listenersAny() ​

listenersAny(): ListenerFn[]

The listeners of every event, added by onAny() and prependAny().

Returns ​

ListenerFn[]

A copy of these listeners; changing it does not change the listeners.

Inherited from ​

Component.listenersAny


listImages() ​

listImages(): Promise<ContainerdImage[]>

List the images of the namespace, each one described as Containerd.getImage does. The images whose content is not complete (a pull in progress, content collected) or that have none of their platforms' content are left out.

Returns ​

Promise<ContainerdImage[]>

The images.


listNetworks() ​

listNetworks(): Promise<ContainerdNetworkInfo[]>

List the networks: host and none, then the CNI networks of cniConfigPath, among them nerdctl's default bridge once it exists (it is created when a container or Containerd.getNetwork first asks for it).

Returns ​

Promise<ContainerdNetworkInfo[]>

The networks.


listVolumes() ​

listVolumes(): Promise<ContainerdVolumeInfo[]>

List the named volumes of the namespace, sorted by name.

Returns ​

Promise<ContainerdVolumeInfo[]>

The volumes.


many() ​

many(event, timesToListen, listener): this

Add a listener called for the event's next emittings, then removed.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

timesToListen ​

number

The number of emittings the listener is called for.

listener ​

ListenerFn

The function called with the event's values, asynchronously after the emitting (in a later turn of the event loop); its result (or the promise it returns) is collected by emitRequest().

Returns ​

this

The component, for chaining.

Inherited from ​

Component.many


off() ​

off(event, listener): this

Remove a listener of an event; nothing happens when it was not added.

Parameters ​

event ​

string | symbol | event[]

The event the listener was added for.

listener ​

ListenerFn

The listener to remove.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.off


offAny() ​

offAny(listener): this

Remove a listener of every event added by onAny() or prependAny().

Parameters ​

listener ​

ListenerFn

The listener to remove.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.offAny


on() ​

on(event, listener): this

Add a listener, after the event's other listeners.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

listener ​

ListenerFn

The function called with the event's values, asynchronously after the emitting (in a later turn of the event loop); its result (or the promise it returns) is collected by emitRequest().

Returns ​

this

The component, for chaining.

Inherited from ​

Component.on


onAny() ​

onAny(listener): this

Add a listener of every event, called synchronously at the emitting, before the event's own listeners.

Parameters ​

listener ​

EventAndListener

The function called with the event name, then the event's values.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.onAny


once() ​

once(event, listener): this

Add a listener called for the event's next emitting only, then removed.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

listener ​

ListenerFn

The function called with the event's values, asynchronously after the emitting (in a later turn of the event loop); its result (or the promise it returns) is collected by emitRequest().

Returns ​

this

The component, for chaining.

Inherited from ​

Component.once


prependAny() ​

prependAny(listener): this

Add a listener of every event, before the other listeners of every event, called synchronously at the emitting.

Parameters ​

listener ​

EventAndListener

The function called with the event name, then the event's values.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.prependAny


prependListener() ​

prependListener(event, listener): this

Add a listener before the event's other listeners.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

listener ​

ListenerFn

The function called with the event's values, asynchronously after the emitting (in a later turn of the event loop); its result (or the promise it returns) is collected by emitRequest().

Returns ​

this

The component, for chaining.

Inherited from ​

Component.prependListener


prependMany() ​

prependMany(event, timesToListen, listener): this

Add a listener called for the event's next emittings, then removed; it is placed before the event's other listeners.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

timesToListen ​

number

The number of emittings the listener is called for.

listener ​

ListenerFn

The function called with the event's values, asynchronously after the emitting (in a later turn of the event loop); its result (or the promise it returns) is collected by emitRequest().

Returns ​

this

The component, for chaining.

Inherited from ​

Component.prependMany


prependOnceListener() ​

prependOnceListener(event, listener): this

Add a listener called for the event's next emitting only, then removed; it is placed before the event's other listeners.

Parameters ​

event ​

string | symbol | event[]

The event: a name ('order.paid', the parts separated by dots, with the wildcards * for one part and ** for any parts) or the parts as an array (['order', 'paid']). A symbol is an event of its own (matched by the wildcard * as a name of one part).

listener ​

ListenerFn

The function called with the event's values, asynchronously after the emitting (in a later turn of the event loop); its result (or the promise it returns) is collected by emitRequest().

Returns ​

this

The component, for chaining.

Inherited from ​

Component.prependOnceListener


preventExtensions() ​

static preventExtensions<T>(o): T

Prevents the addition of new properties to an object.

Type Parameters ​

T ​

T

Parameters ​

o ​

T

Object to make non-extensible.

Returns ​

T

Inherited from ​

Component.preventExtensions


propertyIsEnumerable() ​

propertyIsEnumerable(v): boolean

Determines whether a specified property is enumerable.

Parameters ​

v ​

PropertyKey

A property name.

Returns ​

boolean

Inherited from ​

Component.propertyIsEnumerable


propertyNames() ​

propertyNames(): string[]

The names of the object's own properties (not its class's methods and accessors).

Returns ​

string[]

The names.

Inherited from ​

Component.propertyNames


propertySymbols() ​

propertySymbols(): symbol[]

The symbols of the object's own properties.

Returns ​

symbol[]

The symbols.

Inherited from ​

Component.propertySymbols


prune() ​

prune(options?): Promise<ContainerdPruneResult>

Remove the unused resources of the namespace, in this order: the containers that are not running (created or exited), the images no container uses (the dangling ones, without a tag, or all of them with allImages), the CNI networks no container uses (except the default bridge and the ones nerdctl did not create), and the volumes no container mounts. A container, image, network or volume that fails to be removed is skipped (left out of the result).

Parameters ​

options? ​

ContainerdPruneOptions

What to remove: containers and images by default, allImages, networks and volumes when set.

Returns ​

Promise<ContainerdPruneResult>

The names (identifiers of the containers) of what was removed.


pullImage() ​

pullImage(options): Promise<ContainerdImage>

Pull an image from its registry: the manifests of the platforms asked, their configurations and layers, then unpack the ones the machine runs (Containerd.supportedPlatforms) into the snapshotter so that containers can run them; the other platforms are only stored. The image is named by its normalized reference (docker.io/library/alpine:3.20); an image of the same name is replaced. The pull is aborted when the component is destroyed.

Parameters ​

options ​

ImagePullOptions

The reference, the platforms (the machine's by default, 'all' for every one), the registry credentials (auth, else the registryAuths of its registry), unpack and the progress callback.

Returns ​

Promise<ContainerdImage>

The image pulled.

Throws ​

The image has no manifest for one of the platforms asked.

Throws ​

The registry cannot be reached, refuses the credentials, or does not have the reference; the transfer fails or is aborted; the unpacking fails (the image is stored).


recreateContainer() ​

recreateContainer(record, options): Promise<ContainerdContainer>

Replace a container by a new one created with other settings, as ContainerdContainer.update does: the old container is renamed, the new one created with options, then the old one removed by force, and the new one started when the old one was running or paused. When the creation fails, the old container gets its name back and keeps running.

Parameters ​

record ​

Message

The containerd record of the container to replace.

options ​

ContainerCreateOptions

The complete settings of the new container.

Returns ​

Promise<ContainerdContainer>

The new container.

Throws ​

The container no longer exists.

Throws ​

From the creation, as Containerd.createContainer throws.


reload() ​

reload(): Promise<void>

Destroy the component and initialize it again (same instance): its dependencies are injected again and its init() runs again; its listeners are removed by the teardown. Its configured values are kept.

Returns ​

Promise<void>

Resolves once the component is ready again.

Throws ​

When its parent has been destroyed.

Throws ​

The error of its teardown or of its initialization.

Inherited from ​

Component.reload


removeAllListeners() ​

removeAllListeners(event?): this

Remove the listeners of an event, or all the listeners.

Parameters ​

event? ​

string | symbol | event[]

The event whose listeners are removed; all the listeners when omitted.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.removeAllListeners


removeListener() ​

removeListener(event, listener): this

Remove a listener of an event, as off().

Parameters ​

event ​

string | symbol | event[]

The event the listener was added for.

listener ​

ListenerFn

The listener to remove.

Returns ​

this

The component, for chaining.

Inherited from ​

Component.removeListener


removeNetwork() ​

removeNetwork(nameOrId): Promise<void>

Remove a CNI network created by nerdctl or by the component, as nerdctl network rm does: its configuration, its bridge and the leases of its addresses.

Parameters ​

nameOrId ​

string

Its name, its identifier, or a prefix of its identifier.

Returns ​

Promise<void>

Throws ​

No network matches (host and none included).

Throws ​

A container of the namespace uses it, it is the default bridge, or it was not created by nerdctl (its configuration is left to remove by hand).


removeVolume() ​

removeVolume(name): Promise<void>

Remove a named volume and its data.

Parameters ​

name ​

string

The volume's name.

Returns ​

Promise<void>

Throws ​

The volume does not exist.

Throws ​

A container of the namespace mounts it, even a stopped one.


seal() ​

static seal<T>(o): T

Prevents the modification of attributes of existing properties, and prevents the addition of new properties.

Type Parameters ​

T ​

T

Parameters ​

o ​

T

Object on which to lock the attributes.

Returns ​

T

Inherited from ​

Component.seal


setMaxListeners() ​

setMaxListeners(n): void

Set the number of listeners of one event above which a possible memory leak is warned of (the maxListeners option, 11 by default); the listeners are never limited.

Parameters ​

n ​

number

The number, 0 for no warning.

Returns ​

void

Inherited from ​

Component.setMaxListeners


setProperty() ​

setProperty(propertyKey, value): void

Set a property of the object; the value is not validated, even for a @Configurable property.

Parameters ​

propertyKey ​

string

The property name.

value ​

any

The value.

Returns ​

void

Inherited from ​

Component.setProperty


setPrototypeOf() ​

static setPrototypeOf(o, proto): any

Sets the prototype of a specified object o to object proto or null. Returns the object o.

Parameters ​

o ​

any

The object to change its prototype.

proto ​

object | null

The value of the new prototype or null.

Returns ​

any

Inherited from ​

Component.setPrototypeOf


supportedPlatforms() ​

supportedPlatforms(): string[]

List the platforms this machine runs containers of: its own, and the ones of the emulators registered in binfmt_misc (QEMU, Rosetta), as detected when the component was created or by Containerd.detectPlatforms. An image is described for the first of its platforms in this list.

Returns ​

string[]

A copy of the list, formatted os/architecture[/variant] (linux/arm64/v8, linux/amd64).


toLocaleString() ​

toLocaleString(): string

Returns a date converted to a string using the current locale.

Returns ​

string

Inherited from ​

Component.toLocaleString


toString() ​

toString(): string

Returns a string representation of an object.

Returns ​

string

Inherited from ​

Component.toString


valueOf() ​

valueOf(): Object

Returns the primitive value of the specified object.

Returns ​

Object

Inherited from ​

Component.valueOf


values() ​

Call Signature ​

static values<T>(o): T[]

Returns an array of values of the enumerable own properties of an object

Type Parameters ​
T ​

T

Parameters ​
o ​

{[s: string]: T; } | ArrayLike<T>

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

T[]

Inherited from ​

Component.values

Call Signature ​

static values(o): any[]

Returns an array of values of the enumerable own properties of an object

Parameters ​
o ​

{ }

Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

Returns ​

any[]

Inherited from ​

Component.values


version() ​

version(): Promise<{ revision: string; version: string; }>

Get the version of containerd.

Returns ​

Promise<{ revision: string; version: string; }>

Its version (1.7.36, v2.4.1) and its git revision.

Throws ​

containerd no longer answers (from @lakutata/grpc).

Released under the MIT License.