Class: Docker
The Docker component: drives a Docker daemon over the Docker Engine API, to pull, build, import, export, tag and push images, to create, run and manage containers (exec, TTYs, logs, stats, commit, archives) and to manage networks. Register it in the components of an application ({class: Docker}, or the result of one of the BuildDocker*ConnectionOptions functions) and get it with getObject() or @Inject; it is a singleton.
Without socketPath nor host, it connects to the Docker of the environment: DOCKER_HOST (with DOCKER_TLS_VERIFY, DOCKER_CERT_PATH and DOCKER_CLIENT_TIMEOUT), else the named pipe //./pipe/docker_engine on Windows, the socket of Docker Desktop (~/.docker/run/docker.sock) when it exists, or /var/run/docker.sock; the other options given (timeout, headers, version…) apply over the environment's. No Docker CLI is needed locally (the SSH connections need it on the remote host).
When it is created, the component pings the daemon and negotiates the API version (the newest one supported by both, from 1.41 to 1.56): a daemon which cannot be reached fails its creation with DockerConnectionException. Afterwards, a daemon which cannot be reached rejects the calls with the network error of Node.js (ECONNREFUSED, ENOENT…). A request the daemon refuses rejects with the exception of what is missing (DockerContainerNotFoundException, DockerImageNotFoundException, DockerNetworkNotFoundException), else with a DockerRequestException, whose statusCode is the HTTP status and whose message is the daemon's. The pulls, builds, imports and pushes wrap their failures in their own exceptions (DockerImagePullException…).
When the component is destroyed (the application stopping), the pulls and builds in progress are aborted (they reject with their exception), the listings in progress resolve with an empty list, and its connections are closed.
Example
import {Application} from 'lakutata'
import {Docker, type DockerContainer, type DockerImage} from 'lakutata/com/docker'
Application
.run(() => ({
id: 'docker.app',
name: 'Docker',
components: {
//The Docker of the environment: DOCKER_HOST, else the local socket
docker: {class: Docker}
}
}))
.onLaunched(async (app: Application): Promise<void> => {
const docker: Docker = await app.getObject('docker')
const image: DockerImage = await docker.pullImage({repo: 'alpine', tag: '3.20'})
//Created, then started
const container: DockerContainer = await image.run({name: 'hello', cmd: ['sleep', '60']})
console.log((await container.exec({cmd: ['echo', 'hello']})).stdout)
await container.remove({force: true})
})Extends
Constructors
Constructor
new Docker(
cradleProxy):Docker
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
Docker
Inherited from
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
$symbol
Get Signature
get $symbol():
symbol
A symbol unique to the instance (made from its $uuid), created on first read.
Returns
symbol
Inherited from
$uuid
Get Signature
get $uuid():
string
A random UUID identifying the instance.
Returns
string
Inherited from
className
Get Signature
get
staticclassName():string
The name of the class.
Returns
string
Inherited from
className
Get Signature
get className():
string
The name of the object's class.
Returns
string
Inherited from
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
acceptsOption()
staticacceptsOption(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
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
assign()
Call Signature
staticassign<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
Call Signature
staticassign<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
Call Signature
staticassign<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
Call Signature
staticassign(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
buildImage()
buildImage(
options):Promise<DockerImage>
Build an image with BuildKit, as docker build, and wait for its end. The build context is made of the files of the workdir (relative paths; a directory with its content), without the ones its .dockerignore excludes, and always with the Dockerfile. The progress is given to the output callback as the lines of docker build --progress=plain ({id: 'moby.buildkit.trace', stream: '#2 [1/2] FROM alpine'}).
With auth, the base images of the Dockerfile (its FROM lines) are pulled first with these credentials, as BuildKit is not given them.
Parameters
options
The context (workdir, files), the Dockerfile, the name of the image (repoTag; a generated unnamed_img_… name by default), the platform, the target stage, the build arguments, the registry credentials and the output callback.
Returns
Promise<DockerImage>
The image built.
Throws
When the build fails: a step failing, the Dockerfile or a file of the context missing, a base image which cannot be pulled, the daemon unreachable, or the component destroyed during the build (its message then says it was aborted).
checkRepositoryAuth()
checkRepositoryAuth(
options):Promise<boolean>
Whether a registry accepts credentials (Docker.loginRepository without its error).
Parameters
options
The registry (serverAddress, a host name without protocol) and its credentials.
Returns
Promise<boolean>
true when they are accepted; false on any failure, the daemon unreachable included.
create()
Call Signature
staticcreate(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
Call Signature
staticcreate(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
createContainer()
Call Signature
createContainer(
imageId,options):Promise<DockerContainer>
Create a container from an image, as docker create: it is not started (see DockerContainer.start, or DockerImage.run to create and start it).
Parameters
imageId
string
The ID or the name (alpine:3.20) of a local image: it is not pulled.
options
The container's settings: name, command, environment, ports, binds, devices, networks, limits…
Returns
Promise<DockerContainer>
The container created.
Throws
When the image is not found.
Throws
When a network of the settings is not found.
Throws
When the daemon refuses the settings: the name already used (HTTP 409), an invalid setting (HTTP 400).
Throws
When the settings are invalid.
Call Signature
createContainer(
imageId,platform,options):Promise<DockerContainer>
Create a container from an image for a platform, as docker create --platform: it is not started.
Parameters
imageId
string
The ID or the name (alpine:3.20) of a local image: it is not pulled.
platform
string
The platform of the image used (linux/arm64), for an image having several.
options
The container's settings: name, command, environment, ports, binds, devices, networks, limits…
Returns
Promise<DockerContainer>
The container created.
Throws
When the image is not found for the platform.
Throws
When a network of the settings is not found.
Throws
When the daemon refuses the settings: the name already used (HTTP 409), an invalid setting (HTTP 400).
Throws
When the settings are invalid.
createNetwork()
createNetwork(
options):Promise<NetworkInfo>
Create a network, as docker network create.
Parameters
options
The name, the driver ('bridge' by default, 'ipvlan', 'macvlan'), its options, the subnets (NetworkIPAMConfigs; chosen by the daemon when empty or absent), internal and enableIPv6.
Returns
Promise<NetworkInfo>
The network created.
Throws
When the daemon refuses the network: the name already used (HTTP 409), a subnet overlapping another network's (HTTP 400).
defineProperties()
staticdefineProperties<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
defineProperty()
staticdefineProperty<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
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
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
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
entries()
Call Signature
staticentries<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
Call Signature
staticentries(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
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
freeze()
Call Signature
staticfreeze<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
Call Signature
staticfreeze<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
Call Signature
staticfreeze<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
fromEntries()
Call Signature
staticfromEntries<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
Call Signature
staticfromEntries(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
getContainer()
getContainer(
id):Promise<DockerContainer>
Get a container by its ID, short ID or name, inspected with its image (image is undefined when its image no longer exists, removed with force). The object is a snapshot: its properties are refreshed by its own operations (start(), stop()…), not by the changes made by others.
Parameters
id
string
The ID, a unique prefix of it, or the name of the container.
Returns
Promise<DockerContainer>
The container.
Throws
When the daemon has no such container.
getImage()
getImage(
repoTagOrId):Promise<DockerImage>
Get an image by its ID or its name, resolved by the daemon as docker image inspect does: the full ID (sha256:…), a unique prefix of it (d9e853e8), a tag (alpine:3.20), a name without its tag for :latest (alpine), a name with its registry (docker.io/library/alpine:3.20) or a digest (alpine@sha256:…).
Parameters
repoTagOrId
string
The ID, the short ID, the name or the digest of the image.
Returns
Promise<DockerImage>
The image.
Throws
When the daemon finds no image with this ID or name.
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
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
getNetwork()
getNetwork(
id):Promise<NetworkInfo>
Get a network by its ID, a unique prefix of it, or its name, as docker network inspect.
Parameters
id
string
The ID, a unique prefix of it, or the name of the network.
Returns
Promise<NetworkInfo>
The network.
Throws
When the daemon has no such network.
getOwnPropertyDescriptor()
staticgetOwnPropertyDescriptor(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()
staticgetOwnPropertyDescriptors<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()
staticgetOwnPropertyNames(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
getOwnPropertySymbols()
staticgetOwnPropertySymbols(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
getPrototypeOf()
staticgetPrototypeOf(o):any
Returns the prototype of an object.
Parameters
o
any
The object that references the prototype.
Returns
any
Inherited from
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
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
hasOwn()
statichasOwn(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
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
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
importImage()
importImage(
options):Promise<DockerImage>
Load an image from a tar archive written by docker save (or DockerImage.export), as docker load. The tags saved in the archive are restored.
Parameters
options
The archive (source, a file path or a readable stream) and quiet (false by default).
Returns
Promise<DockerImage>
The image loaded.
Throws
When the daemon rejects the archive, or when the loaded image is unknown.
Throws
The error of the source when it cannot be read (ENOENT for a missing file), or the network error when the archive cannot be sent.
Throws
When the daemon refuses the request.
is()
staticis(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
isExtensible()
staticisExtensible(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
isFrozen()
staticisFrozen(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
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
isSealed()
staticisSealed(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
keys()
Call Signature
statickeys(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
Call Signature
statickeys(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
listContainers()
listContainers():
Promise<DockerContainer[]>
List the daemon's containers, the stopped ones included (as docker ps -a). Each container is inspected, with its image (see Docker.getContainer); a container removed during the listing is not listed.
Returns
Promise<DockerContainer[]>
The containers; an empty list when the component is destroyed during the call.
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
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
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
listImages()
listImages():
Promise<DockerImage[]>
List the daemon's images (as docker images, without the intermediate ones). Each image is inspected with a request of its own, so the call costs one request per image; an image removed during the listing is not listed.
Returns
Promise<DockerImage[]>
The images, in the daemon's order.
listNetworks()
listNetworks():
Promise<NetworkInfo[]>
List the daemon's networks, the reserved ones (bridge, host, none) included.
Returns
Promise<NetworkInfo[]>
The networks; an empty list when the component is destroyed during the call.
loginRepository()
loginRepository(
options):Promise<void>
Check credentials against a registry, as docker login does. The credentials are not kept: each pull, build or push which needs them is given its own auth.
Parameters
options
The registry (serverAddress, a host name without protocol: registry.example.com:5000) and its credentials (a password, or a token).
Returns
Promise<void>
Throws
When the registry refuses the credentials or cannot be reached (the daemon's status: HTTP 401, 500).
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
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
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
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
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
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
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
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
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
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
preventExtensions()
staticpreventExtensions<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
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
propertySymbols()
propertySymbols():
symbol[]
The symbols of the object's own properties.
Returns
symbol[]
The symbols.
Inherited from
prune()
prune(
options?):Promise<void>
Remove the daemon's unused resources, as docker <kind> prune does without options: the stopped containers, then the dangling images (untagged and unused), the unused networks and the unused anonymous volumes. Without options, the containers and the images are pruned; the networks and the volumes only when asked.
Parameters
options?
The kinds of resources pruned: containers and images default to true, networks and volumes to false.
Returns
Promise<void>
Throws
When the options are invalid.
Throws
When the daemon refuses a prune (one already running: HTTP 409).
pullImage()
pullImage(
options):Promise<DockerImage>
Pull an image from its registry, as docker pull, and wait for its end.
Parameters
options
The repository (alpine, registry.example.com:5000/team/app), the tag ('latest' by default), the platform (linux/arm64, the daemon's by default), the registry credentials, and a callback receiving each progress message.
Returns
Promise<DockerImage>
The image pulled, found as repo:tag the way the daemon names it (docker.io/library/alpine is alpine).
Throws
When the pull fails: the image or the registry not found, refused credentials, the daemon unreachable, or the component destroyed during the pull (its message then says it was aborted).
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
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
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
removeNetwork()
removeNetwork(
id):Promise<void>
Remove a network, as docker network rm.
Parameters
id
string
The ID, a unique prefix of it, or the name of the network.
Returns
Promise<void>
Throws
When the daemon has no such network.
Throws
When the network has containers connected (HTTP 409), or is reserved (bridge, host, none: HTTP 403).
seal()
staticseal<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
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
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
setPrototypeOf()
staticsetPrototypeOf(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
toLocaleString()
toLocaleString():
string
Returns a date converted to a string using the current locale.
Returns
string
Inherited from
toString()
toString():
string
Returns a string representation of an object.
Returns
string
Inherited from
valueOf()
valueOf():
Object
Returns the primitive value of the specified object.
Returns
Object
Inherited from
values()
Call Signature
staticvalues<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
Call Signature
staticvalues(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[]