ContainerManager
Defined in: packages/runtime/src/container/types.ts:539
Registry-aware container runtime: create, list, get, destroy, run, and expose as a fileserver.
Consumed — obtain from createContainerManager. Use this (not ContainerRuntime) when containers should be discoverable by name and cleaned up as a group (e.g. at shell exit).
Remarks
Section titled “Remarks”The manager maintains:
- a name → container map,
- a creation-order list (used by
stopAll()to stop in reverse), - restart-timer bookkeeping for
ContainerShorthand.restartpolicies, - optional per-container audit loggers and health-check runners.
Invariant
Section titled “Invariant”Names are unique within a manager — create() with a name already
in use throws EEXIST.
Invariant
Section titled “Invariant”create(image, shorthand) auto-generates a name when shorthand.name
is missing; the legacy create(spec) overload requires the name be
set in the spec.
Invariant
Section titled “Invariant”run() defaults rm: true in the shorthand path — the container
is stopped, removed, and dropped from the registry on return.
Invariant
Section titled “Invariant”fs() returns a stable Fileserver instance (cached on
first call) exposing the manager as a Plan-9 fileserver.
Caveat
Section titled “Caveat”stopAll() is failure-isolated: one container’s stop error does not
block the others. Cancel all pending restart timers as the first step.
Example
Section titled “Example”import { createContainerManager, nodeRuntime } from '@fishnet/runtime'
const mgr = createContainerManager((await nodeRuntime()).caps)const code = await mgr.run(image, { bin: 'echo', argv: ['hi'] })await mgr.stopAll()Extends
Section titled “Extends”Methods
Section titled “Methods”boot()
Section titled “boot()”boot(
image,opts?):Promise<UnixInstance>
Defined in: packages/runtime/src/container/types.ts:494
Legacy: boot an image directly, bypassing the container lifecycle.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<UnixInstance>
Inherited from
Section titled “Inherited from”create()
Section titled “create()”Call Signature
Section titled “Call Signature”create(
image,opts?):Promise<Container>
Defined in: packages/runtime/src/container/types.ts:546
Shorthand API: create a container from image + flat options.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<Container>
Invariant
Section titled “Invariant”Name defaults to an auto-generated unique name when omitted.
Invariant
Section titled “Invariant”Throws EEXIST when the name collides with an existing container.
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”create(
spec,opts?):Promise<Container>
Defined in: packages/runtime/src/container/types.ts:548
Legacy API: create from a fully-built ContainerSpec.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<Container>
Overrides
Section titled “Overrides”ContainerRuntime.create
destroy()
Section titled “destroy()”destroy(
name):Promise<void>
Defined in: packages/runtime/src/container/types.ts:558
Stop (if running) then remove, and drop from the registry.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Invariant
Section titled “Invariant”Cancels any pending restart timer and health runner first.
fs():
Fileserver
Defined in: packages/runtime/src/container/types.ts:576
Plan 9 fileserver view of the manager — mount at e.g. /containers.
Returns
Section titled “Returns”get(
name):Container|undefined
Defined in: packages/runtime/src/container/types.ts:552
Look up a container by name. Returns undefined after remove().
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Container | undefined
list()
Section titled “list()”list():
Container[]
Defined in: packages/runtime/src/container/types.ts:550
All non-removed containers, in creation order.
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”run(
image,opts?):Promise<ExitCode>
Defined in: packages/runtime/src/container/types.ts:565
Shorthand run: create + start + wait + remove. Defaults rm: true.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<ExitCode>
Invariant
Section titled “Invariant”Always removes the container on return (on success, failure, or thrown exception) — resource leak-free.
Call Signature
Section titled “Call Signature”run(
spec):Promise<ExitCode>
Defined in: packages/runtime/src/container/types.ts:567
Legacy API: create + start + wait + remove from a pre-built spec.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<ExitCode>
stopAll()
Section titled “stopAll()”stopAll(
timeout?):Promise<void>
Defined in: packages/runtime/src/container/types.ts:574
Stop all containers in reverse creation order.
Parameters
Section titled “Parameters”timeout?
Section titled “timeout?”number
Returns
Section titled “Returns”Promise<void>
Invariant
Section titled “Invariant”Failure-isolated: one container’s stop failure does not block others.
Invariant
Section titled “Invariant”Cancels all pending restart timers as the first step.