worker-compose.yaml, starts and
stops each worker in dependency order, and supervises the running workers.
The daemon
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
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: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: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
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
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.
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.buildis""is reported asskipped. compose::cancelwith the operation id, orcompose::down, stops the build.
Checking status
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
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
target and targets, and every project it holds with its
namespace, file, and worker states.
Validating a 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
--up, and then the daemon
itself. It answers first with its name, pid, and the projects it is about to stop.
Viewing schema
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
compose::* functions. See
Three names, three jobs.
Precedence
What a namespace may hold
Only lowercasea-z, 0-9, -, and _. Anything else, uppercase included, fails with
INVALID_NAMESPACE.
One daemon to a namespace
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.
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 undercontainers 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 withUNSUPPORTED_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, thenconfig_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 explicitconfig_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
- The machine environment of the Compose daemon. Non-Unicode names and values are skipped.
- The worker’s
env_fileentries, in declaration order. Later files override earlier files. - The worker’s
environmentmap. 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. - The reserved variables, which the daemon owns.
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.
VM workers
A VM worker runs in a microVM. Itsscripts.build builds an image in the sandbox adapter, and its
scripts.run boots that image. Both lines name the container’s own key:
worker-compose.yaml
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
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 setsruntime.base_image stays on the host when its container
declares scripts.build, "" when there is nothing to build:
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: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 withprune=true and add it again:
Upgrade a project from an older release
On its firstup, 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
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
<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.
Related
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.