Skip to main content
Compose runs a group of workers as one project. The daemon reads a worker-compose.yaml, starts and stops each worker in dependency order, and supervises the running workers.

The daemon

The daemon is a worker named compose, so every project operation is a function call to compose::*. iii compose --up is about the same as running iii, iii compose, and iii call compose::up separately. Run iii and iii compose separately when the engine needs its own lifecycle. See The daemon and its processes.

Starting a project with the daemon

Ctrl^C, SIGINT, SIGTERM, and SIGHUP stop the daemon, its workers, and the engine it started with --up. compose::stop does the same from a function call. An engine Compose did not start keeps running.

Process names on Linux

The daemon is labelled iii:c:<namespace> and an engine it started iii:e:<namespace>. For example, iii compose --namespace orders --up shows:
comm abbreviates a namespace longer than nine characters. Read the full namespace in args. See Process names.

Compose logs

Each line starts with the worker name. The files are in logs/ of the state directory, and the managed engine writes engine.log there. See Log files.

Running it in the background

Compose does not daemonize itself. Use shell backgrounding:
Or a systemd unit:
Use Type=simple. Type=notify waits for an sd_notify readiness message, which compose does not send.

The compose::* functions

These functions control a running daemon and edit worker-compose.yaml:
file is optional when the daemon holds one project. A relative file is relative to the daemon’s directory, not yours; an absolute path also works. See Which project a call reaches.

Starting a project

Workers that are already ready stay as they are. A container with no build yet gets its first build before it runs.

compose::up failures

Make a worker’s failed start fail the operation:
Or set the fallback for every container in the file. A container’s own value wins:
A worker is not required by default: its failure is listed in not_required_failures, and the operation still returns status: ok with no top-level error. A required failure ends the operation with PROJECT_DID_NOT_START and rolls back the partial start in reverse dependency order. See Saying it in the file.

Retrying a worker that fails

Or, to change the limits:
no is the default. on-failure retries a failed start or a non-zero exit. always also restarts a worker that exits successfully after it was ready. See Retry policy.

Stopping a project

Adding workers

To set container fields, pass a JSON list that mixes names and container objects:
A container object accepts these fields: The container key is the last part of the worker name or path. A selector such as state@next stays as written in the file. For an existing container, a supplied field replaces that whole field; use {} or [] to clear it. A VM worker gets its scripts and start_after written for it (see VM workers). See How compose::add edits a project.

Package lock

Commit the lock so development, CI, and deployments use the same package content. Files that differ only by extension share one lock; use different stems when you need independent locks. See The package lock.

Removing a worker

compose::remove removes a worker from the compose file and stops it. The other workers keep running.
Removing a worker does not remove the workers that were added with it. Remove them explicitly. A VM worker keeps its data unless you pass prune=true, and a container added again under the same key boots with that data. See Removing a VM worker.

Restarting one worker

compose::restart stops a worker and starts it again. The other workers, its dependencies included, keep running. A restart never runs scripts.build.
Restarting the sandbox adapter (worker=sandbox-libkrun) also restarts every VM worker it runs. See Restarting the sandbox adapter.

Updating workers

compose::update moves declared registry workers to newer versions, together with their dependencies. To add a worker, use compose::add.
path:// workers have no version: an update skips them, and a restart picks up their changes.
An update that changes package content or graph topology restarts the whole project once.
For what an update resolves, downloads, and rebuilds, see Updating packages.

Building workers

compose::build runs scripts.build again for one container, or for every container that declares one. The running container keeps its current build until it restarts, so restart it once the build is done:
  • The call answers at once with an operation_id. The container’s logs show the build, each line with the [build] prefix.
  • A container whose scripts.build is "" is reported as skipped.
  • compose::cancel with the operation id, or compose::down, stops the build.
The finished operation carries one result per container:
For what a failed or cancelled build leaves, see Rebuilds.

Checking status

Each worker has its state, version (the locked version, or local for a path:// worker), requested selector, pid, owned, log_path, and last_error when there is one. owned is false for a worker the daemon knows about but did not start. See What compose::status reports.

Worker states

Listing processes

Lists the daemon, its managed engine, every worker, and the processes those workers started. Omit file for every project of the daemon. Each entry has pid, ppid, kind (engine, compose or worker), name (the worker’s container key), ports, compose_file, orphan, started_at (seconds since the Unix epoch), and command. orphan is true for a worker of the project that no Compose daemon supervises. For every iii process on the machine, use iii ps.

Viewing logs

The response holds one entry per worker with container, entries (each with stream and message), cursor (generation and offset), and truncated, which is true when the cursor sent is older than the retained archives.

Listing projects

Returns the daemon name, namespace, pid, target and targets, and every project it holds with its namespace, file, and worker states.

Validating a file

Validation is offline and never edits the file: package:// workers are listed under deferred_packages, not resolved. When the next up would rewrite containers into the explicit VM mode, a warning names them (only packages the lock already records as bundles):

Validation reports

Stopping the daemon

Stops every project and worker of the daemon, the engine it started with --up, and then the daemon itself. It answers first with its name, pid, and the projects it is about to stop.
There is no compose::start equivalent to compose::stop. Stopping a compose daemon means it must be restarted from the server it is running on.

Viewing schema

With no function_id, it returns every compose::* schema. The pseudo-id worker-compose.yaml returns the file’s JSON Schema as request and a small example as response. Each entry holds function_id, description, request, response, default_timeout_ms, and idempotent, as engine::functions::info does.

Configure a namespace

Or override it when you start the daemon:
Use the same namespace in calls and observers that target the project’s workers and its compose::* functions. See Three names, three jobs.

Precedence

What a namespace may hold

Only lowercase a-z, 0-9, -, and _. Anything else, uppercase included, fails with INVALID_NAMESPACE.

One daemon to a namespace

Only one Compose daemon can serve a namespace on a iii engine. A second one fails with DAEMON_ALREADY_SERVING. Give each daemon its own namespace when several share one engine.

worker-compose.yaml

Below is an example of version 1 of a worker compose file. Unknown keys and duplicate keys are errors. Durations can specify a unit such as: 500ms, 30s, 2m.

Top-level fields

Engine fields

Allowed worker keys are configuration, iii-worker-manager, iii-http-functions (deprecated; still accepted), and iii-stream (deprecated; still accepted). Use #instance for another instance of an allowed type, for example iii-worker-manager#rbac. The engine injects iii-engine-functions, iii-telemetry for anonymous usage analytics, iii-observability for OpenTelemetry traces, metrics, and logs, and the iii-sandbox router. Do not declare these workers. A file that declares iii-sandbox under engine.workers fails with SANDBOX_CONFIG_MOVED, which prints the replacement; see Upgrading to the sandbox worker. engine.sandbox takes adapter, the adapter’s function prefix (sandbox-libkrun by default), and namespace, where the adapter runs (this project’s namespace by default). A managed engine is bound to an adapter whether or not the section is present. Setting the section, with namespace unset or this project’s, also makes Compose install that adapter, as does a container whose scripts.run starts with iii call sandbox::start, or iii call compose::add worker=iii-sandbox. See Sandboxes.
iii-stream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. See Migrate from iii-stream and pubsub.
Changes to these worker configurations take effect only after the engine restarts.

Which engine Compose uses

Compose takes the engine address from the first of these that supplies one: the --engine flag, the III_URL environment variable, the engine: section of the compose file, then ws://127.0.0.1:49134. An address from --engine or III_URL names an engine that already runs, so Compose connects to it and starts no engine of its own, even with --up. Only the compose file can give Compose an engine to own, and only --up takes it: an engine: section carries the engine’s whole configuration, not only an address.

Worker fields

Each key under containers is the name the worker registers under. It also names the container’s directories, .iii/build/<key>/ and .iii/workers/<key>/, so it must be a plain directory name: a key that is empty, holds / or \, starts with ., or holds a NUL fails with INVALID_CONTAINER_KEY. path:// directories resolve against the compose file’s directory. A missing directory fails with MISSING_WORKER_DIRECTORY, and a missing env_file fails with MISSING_ENV_FILE during validation. A path:// worker runs as a host process unless its scripts run it in a VM. A non-empty runtime.base_image in its iii.worker.yaml is the base image of its VM build. Such a worker stays on the host only when it declares its own scripts.build; without one, Compose rewrites it into the VM. See VM workers. An invalid image reference fails instead of falling back to the host or to another image. sandbox-libkrun 0.3.1 and later hide the .iii directory, which holds Compose’s state and the project’s token, from a VM, both in its copy of the worker’s directory and in the source share that copy is made from. Earlier versions do not, so there a VM worker whose directory contains the compose file, such as path://., can read that token. Its disk keeps those bytes after the upgrade, so stop Compose and run iii compose --up once to replace the token: updating or restarting the adapter keeps it. A managed engine also writes data/ and config/ in the directory iii compose --up runs from, and data/ holds the payloads of traced function calls. A VM worker whose directory contains them can read them on any version. So keep the compose file and the directory you start Compose from outside the worker’s directory, as in path://./api. III_COMPOSE_STATE_DIR moves Compose’s state and the token, but not data/ or config/. Point it outside the worker’s directory, because only the name .iii is hidden.

Worker kinds

Worker packages can be released in multiple different “kinds”. A kind compose cannot run fails with UNSUPPORTED_PACKAGE_KIND. A VM worker runs in the sandbox-libkrun worker, a container of the project that the VM worker names in start_after. Compose adds that container when the project needs it. Its guest and its build VM receive the container’s environment and env_file variables and the reserved III_* variables, not the host’s environment: declare under environment what the worker needs, such as a provider key. The adapter is built for three targets only: aarch64-apple-darwin, x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu. On a musl Linux or Intel Mac host Compose fails with UNSUPPORTED_PLATFORM. On Linux the user running Compose needs read and write access to /dev/kvm, and libcap-ng0 must be installed. Every other worker kind is unaffected. On Windows, a bundle fails with BUNDLE_NEEDS_A_VM before anything is downloaded, and Compose refuses a container whose scripts.run is iii call sandbox::start with SANDBOX_UNSUPPORTED_PLATFORM. iii compose build, frozen or not, cannot build or lock such a project there either: the sandbox-libkrun package it resolves ships no Windows build, so it stops with UNSUPPORTED_PLATFORM. Lock and build a project with VM containers on Linux or macOS. Run compose under WSL, where the VM still needs /dev/kvm and a guest rootfs to boot. Every other worker kind runs on windows as it always has. Bundle support can be refused machine-wide with III_BUNDLE_WORKERS_DISABLED=1, which compose honours.

Scripts

Both hooks run with the worker’s environment, working directory, and their own process group. A post_run runs after the worker stops but before the compose daemon exits. The top-level stop_timeout argument is a global timer for a compose daemon to stop. If this time is exceeded all scripts will be exited along with the compose daemon. A path worker’s start command is scripts.run in worker-compose.yaml, or scripts.start in the worker’s own iii.worker.yaml when run is absent. A worker with neither fails with MISSING_START_COMMAND.

scripts.build

Configuration precedence

Lowest to highest: the configuration a package ships, the entry in the configuration worker, then config_override. Maps merge key by key; arrays and scalars replace. A mapping whose name the override changes is replaced whole: the keys beside name belong to the variant it picks. The merged result is delivered through configuration::set with flush: false before the worker starts, unless it is null: an injected null would hide the stored entry, including the default a worker seeds there with configuration::ensure. III_CONFIG_NAME identifies the entry read through configuration::get. Compose does not create an execution snapshot file or set III_CONFIG. The persistent config/<id>.yaml remains unchanged by this memory-only update. configuration::ensure seeds defaults only into the base and preserves the active value. configuration::set with flush: true (the default) persists the complete submitted object, including values originally supplied by an override. Both forms notify consumers. Each start reads the current configuration with configuration::get and raw: true, then applies the declared override. Removing a field from the override keeps its current value; it does not restore the value from disk. Stopping a worker leaves the active value available. Restarting the configuration service discards unsaved memory values and reloads its adapter. Read or update failures stop startup with CONFIG_FETCH_FAILED, rather than silently falling back to defaults.

Readable configuration names and migration

Without an explicit config_name, the entry id is exactly <namespace>-<container-key>. For example, default plus harness uses default-harness and the filesystem adapter stores config/default-harness.yaml. The id must match [a-z0-9_-]{1,64}. Compose rejects an invalid or long generated name with INVALID_CONFIG_NAME and asks for an explicit config_name; it never sanitizes, truncates, or adds a hash. Explicit names remain unchanged and are never auto-migrated. Before reading configuration or starting the child, Compose asks the configuration authority to migrate the exact hashed id produced by the previous algorithm for that namespace and key. default-harness-a14f3656efb8d5ea therefore becomes default-harness. Stored raw values (including ${VAR}, false, 0, and null), name, description, metadata, and available schema are preserved. The filesystem adapter updates both filename and internal id, and the authority updates its caches and notifies subscribers. It re-reads the source so manual edits awaiting the watcher are retained. Migration gives the legacy source priority over an existing destination. After that, the default namespace adopts the exact bare container key (state becomes default-state), even when the destination already exists. The bare source replaces the whole destination entry, preserving raw values and metadata rather than merging defaults. Another container’s explicit ownership blocks this adoption; other namespaces and explicit config_name values never adopt bare entries. After publishing the destination, the fs adapter archives the original source as <source>.yaml.bak (for example, state.yaml.bak). The previous destination is replaced, not backed up. Files ending in .yaml.bak, .bak.yaml, or .bkup.yaml are ignored during loading, watching, and legacy directory migration. Repeated starts with no source perform no writes. An existing identical backup permits recovery after interrupted cleanup; a conflicting backup is never overwritten and stops migration with an error. Migration commits the complete destination before archiving the source. I/O failures stop startup; failure after publication can leave two recoverable copies. The filesystem adapter requires same-directory hard-link support and may normalize YAML formatting or remove comments on the one migration rewrite; values and unknown document fields are retained. Stop source consumers before migration: Compose checks that the child is not already registered, and its restart path stops the old child first. Do not run two configuration authorities against the same directory or edit the source concurrently with migration. The bridge delegates migration to the remote authority. Upgrade that authority together with Compose: an absent configuration::migrate or unsupported adapter fails with CONFIG_MIGRATION_FAILED, never a read/copy/delete fallback that could reset stored values. Within one project, a generated name colliding with another container’s explicit name is rejected before startup. Sharing is allowed only when both names are explicit. Across namespaces, a-b / c and a / b-c both produce a-b-c; choose unambiguous namespaces or distinct explicit config_name values. Readable names do not claim cross-project ownership.

The worker environment

From lowest to highest precedence, a worker gets:
  1. The machine environment of the Compose daemon. Non-Unicode names and values are skipped.
  2. The worker’s env_file entries, in declaration order. Later files override earlier files.
  3. The worker’s environment map. Nonempty values override env files; an empty string preserves an existing env-file value, or supplies an empty value when no env file defines the key.
  4. The reserved variables, which the daemon owns.
Export machine variables before you start the daemon, and only start workers you trust with that environment, credentials included. See Where a worker’s environment comes from. Declaring a reserved variable in environment or an env_file fails with RESERVED_ENV_OVERRIDE. A VM container’s scripts get the requests of iii call sandbox::build and iii call sandbox::start in III_CALL_DEFAULTS, described in Sandboxes / Environment variables. Compose also sets these reserved variables: A package container on the host gets the three package variables when it is a bundle or declares scripts: a host scripts.run of a binary package finds its build in III_PACKAGE_DIR. A VM container gets III_PACKAGE_DIR and III_PACKAGE_NAME, and the package’s kind is in III_CALL_DEFAULTS. III_BUILD_TIMEOUT_MS and III_BUILD_BASE_IMAGE are reserved too, and not set.

Expanding values from environment variables

${VAR} references expand in any value, not only in environment.
config_override is never expanded, all values are treated as literals.

VM workers

A VM worker runs in a microVM. Its scripts.build builds an image in the sandbox adapter, and its scripts.run boots that image. Both lines name the container’s own key:
A project with VM workers, and one worker that stays on the host:
worker-compose.yaml
The sandbox adapter (sandbox-libkrun) is a container like any other: Compose adds it when a container needs it. For how builds and runs behave, see Understanding iii / Compose. For the rules, the files Compose writes, and the error codes, see Reference / VM workers.

Run a worker in a VM

A local worker whose iii.worker.yaml sets runtime.base_image runs in a VM: when its container declares no scripts.build, Compose writes the two lines for it.

Keep a worker on the host

A local worker whose manifest sets runtime.base_image stays on the host when its container declares scripts.build, "" when there is nothing to build:
A registry bundle stays on the host when its scripts.run is a host command. Moving a worker between the host and a VM is an edit of its scripts.

Rebuild a VM worker

The running worker keeps its current image until it restarts. Build, then restart:
Rebuild after you add a dependency: dependencies come from the build, so edit package.json, or the worker’s other dependency file, then build and restart. When the dependency files or the base image changed since the last build, the worker’s logs say so and name this command. Compose rebuilds by itself when compose::add or compose::update changes a worker’s package.

Reset a VM worker’s data

A VM worker’s data disk keeps what the worker writes across restarts and rebuilds. To start again from empty data, remove the worker with prune=true and add it again:

Upgrade a project from an older release

On its first up, Compose rewrites the VM containers of a compose file from an older release. See Upgrading / VM workers.

Build registry packages

iii compose build writes the lock and downloads every package:// worker into the cache compose::up uses, without an engine, workers, or hooks. It does not run scripts.build; compose::build does. If it fails with BUILD_PLAN_STALE, run it again. See How iii compose build prepares packages.

Readiness

A worker is ready once the engine reports a worker of that name in the project’s namespace, within the worker’s startup_timeout. When it is not, the operation fails with one of these codes: See Engine observed readiness for how Compose watches a worker after it is ready.

Where compose keeps state

State is in <project-dir>/.iii/compose/<namespace>/, beside the canonical compose file. For a read-only project directory, set III_COMPOSE_STATE_DIR to a writable directory. Add **/.iii/compose/ to .gitignore. See Why state belongs to the project and The project tree.

Finding and stopping iii processes

STATUS is orphan for a worker whose Compose daemon is gone, and no engine for a worker whose engine port has no engine listening. iii kill exits with 1 when nothing matches or a process is still running afterwards. See How iii ps and iii kill find processes.

Error codes

Compose can output the following error codes: These are literal diagnostic identifiers emitted by Compose, not worker categories. ENGINE_WORKER_IS_BUILTIN reports that a worker declared under containers is already supplied by the engine. Its name is retained for compatibility; it does not define a separate worker type. All workers follow the same model: a worker hosts functions, which are called and observed.
For why compose is a worker see Understanding iii / Compose. For understanding namespaces see Understanding iii / Namespaces. For the iii compose entry in the command tree, see the CLI reference.