Skip to content

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.

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.

new ContainerManagerImpl(caps): ContainerManagerImpl

Defined in: packages/runtime/src/container/runtime.ts:61

PlatformCapabilities

ContainerManagerImpl

ContainerRuntimeImpl.constructor

readonly auditLoggers: Map<string, AuditLogger>

Defined in: packages/runtime/src/container/runtime.ts:107


readonly healthRunners: Map<string, HealthCheckRunner>

Defined in: packages/runtime/src/container/runtime.ts:106

boot(image, opts?): Promise<UnixInstance>

Defined in: packages/runtime/src/container/runtime.ts:69

Legacy: boot an image directly, bypassing the container lifecycle.

UnixImage

BootOpts

Promise<UnixInstance>

ContainerManager.boot

ContainerRuntimeImpl.boot


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.

UnixImage | ContainerSpec

CreateOpts | ContainerShorthand

Promise<Container>

ContainerManager.create

ContainerRuntimeImpl.create


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.

string

Promise<void>

ContainerManager.destroy


fs(): Fileserver

Defined in: packages/runtime/src/container/runtime.ts:110

Plan 9 fileserver view of the manager — mount at e.g. /containers.

Fileserver

ContainerManager.fs


get(name): Container | undefined

Defined in: packages/runtime/src/container/runtime.ts:428

Look up a container by name. Returns undefined after remove().

string

Container | undefined

ContainerManager.get


list(): Container[]

Defined in: packages/runtime/src/container/runtime.ts:422

All non-removed containers, in creation order.

Container[]

ContainerManager.list


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.

UnixImage | ContainerSpec

ContainerShorthand

Promise<ExitCode>

ContainerManager.run


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.

number

Promise<void>

ContainerManager.stopAll