Skip to content

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).

The manager maintains:

  • a name → container map,
  • a creation-order list (used by stopAll() to stop in reverse),
  • restart-timer bookkeeping for ContainerShorthand.restart policies,
  • optional per-container audit loggers and health-check runners.

Names are unique within a manager — create() with a name already in use throws EEXIST.

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.

run() defaults rm: true in the shorthand path — the container is stopped, removed, and dropped from the registry on return.

fs() returns a stable Fileserver instance (cached on first call) exposing the manager as a Plan-9 fileserver.

stopAll() is failure-isolated: one container’s stop error does not block the others. Cancel all pending restart timers as the first step.

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()

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

Defined in: packages/runtime/src/container/types.ts:494

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

UnixImage

BootOpts

Promise<UnixInstance>

ContainerRuntime.boot


create(image, opts?): Promise<Container>

Defined in: packages/runtime/src/container/types.ts:546

Shorthand API: create a container from image + flat options.

UnixImage

ContainerShorthand

Promise<Container>

Name defaults to an auto-generated unique name when omitted.

Throws EEXIST when the name collides with an existing container.

ContainerRuntime.create

create(spec, opts?): Promise<Container>

Defined in: packages/runtime/src/container/types.ts:548

Legacy API: create from a fully-built ContainerSpec.

ContainerSpec

CreateOpts

Promise<Container>

ContainerRuntime.create


destroy(name): Promise<void>

Defined in: packages/runtime/src/container/types.ts:558

Stop (if running) then remove, and drop from the registry.

string

Promise<void>

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.

Fileserver


get(name): Container | undefined

Defined in: packages/runtime/src/container/types.ts:552

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

string

Container | undefined


list(): Container[]

Defined in: packages/runtime/src/container/types.ts:550

All non-removed containers, in creation order.

Container[]


run(image, opts?): Promise<ExitCode>

Defined in: packages/runtime/src/container/types.ts:565

Shorthand run: create + start + wait + remove. Defaults rm: true.

UnixImage

ContainerShorthand

Promise<ExitCode>

Always removes the container on return (on success, failure, or thrown exception) — resource leak-free.

run(spec): Promise<ExitCode>

Defined in: packages/runtime/src/container/types.ts:567

Legacy API: create + start + wait + remove from a pre-built spec.

ContainerSpec

Promise<ExitCode>


stopAll(timeout?): Promise<void>

Defined in: packages/runtime/src/container/types.ts:574

Stop all containers in reverse creation order.

number

Promise<void>

Failure-isolated: one container’s stop failure does not block others.

Cancels all pending restart timers as the first step.