ContainerManagerImpl
Defined in: packages/runtime/src/container/runtime.ts:100
Registry-aware IContainerManager implementation — tracks named containers, runs restart supervision, and exposes a fileserver view.
Remarks
Section titled “Remarks”Extends ContainerRuntimeImpl with:
- name → container registry (with uniqueness + auto-generated names),
- creation-order list (used by stopAll in reverse),
- restart-timer bookkeeping driven by RestartTracker,
- optional per-container audit loggers and health-check runners,
- the Fileserver view built by
containerFS().
Prefer createContainerManager over direct construction. See ContainerManager for the contract this class fulfils.
Extends
Section titled “Extends”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ContainerManagerImpl(
caps):ContainerManagerImpl
Defined in: packages/runtime/src/container/runtime.ts:61
Parameters
Section titled “Parameters”Returns
Section titled “Returns”ContainerManagerImpl
Inherited from
Section titled “Inherited from”ContainerRuntimeImpl.constructor
Properties
Section titled “Properties”auditLoggers
Section titled “auditLoggers”
readonlyauditLoggers:Map<string,AuditLogger>
Defined in: packages/runtime/src/container/runtime.ts:107
healthRunners
Section titled “healthRunners”
readonlyhealthRunners:Map<string,HealthCheckRunner>
Defined in: packages/runtime/src/container/runtime.ts:106
Methods
Section titled “Methods”boot()
Section titled “boot()”boot(
image,opts?):Promise<UnixInstance>
Defined in: packages/runtime/src/container/runtime.ts:69
Legacy: boot an image directly, bypassing the container lifecycle.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<UnixInstance>
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”create()
Section titled “create()”create(
imageOrSpec,optsOrCreateOpts?):Promise<Container>
Defined in: packages/runtime/src/container/runtime.ts:123
Overload dispatch for create: shorthand path (image + ContainerShorthand)
vs legacy path (ContainerSpec + CreateOpts). The isUnixImage guard is
the type-safe discriminator — UnixImage.createBootContext is not a
field on ContainerSpec, so the narrowing is sound.
Parameters
Section titled “Parameters”imageOrSpec
Section titled “imageOrSpec”optsOrCreateOpts?
Section titled “optsOrCreateOpts?”CreateOpts | ContainerShorthand
Returns
Section titled “Returns”Promise<Container>
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”destroy()
Section titled “destroy()”destroy(
name):Promise<void>
Defined in: packages/runtime/src/container/runtime.ts:446
Stop (if running) then remove, and drop from the registry.
Timer + health-runner cancellation happen BEFORE stop() because stop-wrapper also cancels them, but only under its own name binding; calling them here is belt-and-braces for operators who invoke destroy() on a container that got into an odd state.
Audit logger is disposed here (not in container.remove()) because the logger lifecycle is owned by the manager — the container doesn’t know about audit unless the manager told it to.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”fs():
Fileserver
Defined in: packages/runtime/src/container/runtime.ts:110
Plan 9 fileserver view of the manager — mount at e.g. /containers.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”get(
name):Container|undefined
Defined in: packages/runtime/src/container/runtime.ts:428
Look up a container by name. Returns undefined after remove().
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Container | undefined
Implementation of
Section titled “Implementation of”list()
Section titled “list()”list():
Container[]
Defined in: packages/runtime/src/container/runtime.ts:422
All non-removed containers, in creation order.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”run(
imageOrSpec,opts?):Promise<ExitCode>
Defined in: packages/runtime/src/container/runtime.ts:506
Create + start + wait + remove. The finally block is load-bearing: on
any path (success, thrown wait, thrown start), the container must leave
the registry or callers get a name-collision on their next run() with
the same name.
Shorthand path defaults rm: true so behavior matches docker run --rm;
the legacy spec path preserves the pre-existing semantic (always remove)
because --rm wasn’t a concept when that overload shipped.
Parameters
Section titled “Parameters”imageOrSpec
Section titled “imageOrSpec”Returns
Section titled “Returns”Promise<ExitCode>
Implementation of
Section titled “Implementation of”stopAll()
Section titled “stopAll()”stopAll(
timeout?):Promise<void>
Defined in: packages/runtime/src/container/runtime.ts:477
Stop all containers in reverse creation order, with per-container failure isolation.
Reverse order respects dependency direction — callers that start “database, then app” (in that order) expect shutdown as “app, then database”. Cancel-then-stop ordering is critical: if we cancelled restart timers after stopping, a container could be restarted by a timer between its stop() resolving and the cancel reaching it.
Parameters
Section titled “Parameters”timeout?
Section titled “timeout?”number
Returns
Section titled “Returns”Promise<void>