Skip to main content
In 0.26, Compose decided by itself that a worker ran in a microVM: a registry bundle, or a path:// worker whose iii.worker.yaml sets runtime.base_image. Nothing in worker-compose.yaml said so. Now a VM worker says so in the file:
worker-compose.yaml
  • The file shows where each worker runs. iii call sandbox::build asks the sandbox adapter to build an image of the worker, locally, and leaves it in <project>/.iii/build/<container>/. iii call sandbox::start boots that image. worker= is the container’s own key. Moving a worker between a VM, the host, and Docker is an edit of scripts.
  • Build and run are separate. A run never installs dependencies, and a restart repeats the run only. The first build is automatic. Later rebuilds are explicit, except after a package update.
  • Compose rewrites 0.26 files on the next run. Each container that 0.26 ran in a VM gets scripts.build, scripts.run, and the adapter in start_after. A migrated file no longer loads in 0.26.
  • The sandbox adapter must be a 0.5 release (^0.5). Compose updates the adapter container it generated. One you declared yourself fails with SANDBOX_ADAPTER_TOO_OLD until you update it.
  • No VM data is deleted. The data disk a 0.26 VM wrote is kept as upper.ext4.pre-build, and removing a VM container keeps its data unless you ask for prune.
  • Binary packages can run in a VM. A container that sets runtime.base_image runs the package’s Linux build in a VM, and a binary package on the host may set scripts.

Before you upgrade

Compatibility

The new keys are scripts.build, scripts.build_timeout, runtime.base_image, and scripts.run on a package. In any project, with or without a VM worker, a container key is now also the name of its directories, .iii/build/<key>/ and .iii/workers/<key>/. A key that is empty or blank, holds / or \, starts with ., or holds a NUL, such as .internal or a/b, loaded in 0.26 and now fails with INVALID_CONTAINER_KEY. Rename such keys before the first run of the new release, and the start_after entries that name them.
  • Sandbox adapter. VM workers need a sandbox-libkrun 0.5 release (^0.5), the releases with worker.build, worker.binary, and worker.prune (sandbox contract 1.4). A project whose only use of the adapter is ephemeral sandboxes keeps its 0.3.x adapter.
  • Docker. Not required. The default adapter builds inside its own VM.
  • Windows. Unchanged: a bundle fails at install with BUNDLE_NEEDS_A_VM. A container whose scripts.run is iii call sandbox::start fails with SANDBOX_UNSUPPORTED_PLATFORM.

Commit the compose file first

The rewrite edits worker-compose.yaml, and the adapter update edits worker-compose.lock. Commit both before the first run of the new release, so you can roll back:

What changed

The project gains two directories, .iii/workers/ (a copy of each package) and .iii/build/ (one directory per container that has a build). See The project tree. Each VM’s data disk stays under ~/.iii/sandbox/workers/<vm_id>/.

Upgrade a project

  1. Stop the running project: Ctrl^C on iii compose --up, or iii call compose::stop.
  2. Commit worker-compose.yaml and worker-compose.lock, as in Commit the compose file first.
  3. Upgrade iii.
  4. Rename any container key that starts with . or holds / or \, and the start_after entries that name it, as in Compatibility. For each container that must stay on the host, edit its scripts as in Keep a worker on the host. The rules are in How Compose rewrites a container.
  5. If you declared the sandbox-libkrun container yourself (it has no # added by compose::add comment), set its version to "^0.5". Compose updates a generated adapter container itself. See Update the sandbox adapter.
  6. Preview the rewrite. iii compose build needs no engine and no daemon, and boots no VM. It updates or adds the generated adapter container and the lock, rewrites the containers, and fills .iii/workers/ from the lock. It does not run scripts.build:
    Move a container that was rewritten by mistake back to the host, as in Move a container back to the host.
  7. Start the project once without --frozen:
    Compose rewrites any container that is still due, and logs one line per container:
    Each rewritten container then starts. Compose stops a VM that a 0.26 daemon left running, runs the first build, and runs the worker. The log shows <container>: no build yet; running scripts.build, then the build output.
  8. Review the changes to worker-compose.yaml and worker-compose.lock, and commit them:
If you already run iii and iii compose separately, compose::validate lists the containers the next up rewrites, without editing the file:
Run both in the project directory: the daemon resolves file= in its own working directory. iii creates or uses a config.yaml there. The engine must listen on the engine.url of the compose file, because the daemon connects to that address.
If the stop or the build fails, the container fails with that error and the file stays migrated. The next up retries the start: the stop, the first build, and the run.

How Compose rewrites a container

The check is per container and idempotent, keyed on scripts alone. The lock format does not change. Compose rewrites:
  • a bundle package without scripts.run (0.26 refused scripts.run on packages);
  • a path:// whose manifest sets runtime.base_image and that has no scripts.build (0.26 refused the key), whatever its scripts.run: none, or a command;
  • any container whose scripts.run is iii call sandbox::start and that lacks scripts.build or the adapter in start_after. Compose adds only those pieces.
For each one, Compose writes:
  • the adapter’s container key in start_after;
  • scripts.build: iii call sandbox::build worker=<container>;
  • scripts.run: iii call sandbox::start worker=<container>, or, when the container had a scripts.run that 0.26 ran inside the VM, scripts.run: iii call sandbox::start worker=<container> 'command=<that command>'. The argument is single-quoted, and each ' in it is written as '\''. An argument of letters, digits, and ._-:/@%+,= only is written without quotes.
Other keys you set are kept, and so are the comments and the rest of the file. A bundle without scripts.run, before and after:
When the rewrite wraps a scripts.run command, Compose also logs a warning:
Compose validates the result before it writes. A rewrite that would break a rule, such as a bundle whose scripts.build is not iii call sandbox::build, or iii call sandbox::start on a container that cannot run in a VM, is refused with that rule’s code, and the file is left untouched. The rules are in Which containers run in a VM. The rewrite runs in compose::up (and iii compose --up), compose::add, compose::update, compose::restart, compose::build, and iii compose build. compose::validate, compose::ps, compose::status, iii compose logs, compose::down, and compose::remove never edit the file. Compose also reads a 0.26 state.json that holds a vm record once: it stops that VM with worker::stop and drops the record.

Keep a worker on the host

A container that the file places on the host is not rewritten. Edit it before the first iii compose build or iii compose --up of the new release. A path:// whose manifest sets runtime.base_image stays on the host when it declares its own scripts.build, "" when there is nothing to build:
A build: key without a value counts as absent, and Compose rewrites that container into the VM. A bundle stays on the host when its scripts.run is a host command. It runs scripts.build and scripts.run in .iii/workers/<container>/, and gets III_PACKAGE_DIR and III_PACKAGE_NAME. Both are edits of scripts, and later runs leave them alone, with or without a lock.

Move a container back to the host

To move a container back to the host after Compose rewrote it, set scripts.build to the host build command, or "", and scripts.run to the host command. For a path:// worker that 0.26 started with a scripts.run command, that command is the one in 'command=...'.

CI and --frozen

--frozen never edits the file. A file with a container to rewrite fails with VM_SCRIPTS_MISSING, naming the containers and asking for one iii compose --up without --frozen. That check comes first, even when the adapter is missing: the up it asks for adds the adapter too. Only then does --frozen refuse a missing adapter with SANDBOX_ADAPTER_NOT_DECLARED, or, in a project with a VM worker, an adapter outside ^0.5 with SANDBOX_ADAPTER_TOO_OLD. Run iii compose build or iii compose --up once without --frozen where you can commit the result. iii compose build makes the migration commit without starting the project, as in step 6 of Upgrade a project. Commit worker-compose.yaml and worker-compose.lock, and keep --frozen in CI.

Update the sandbox adapter

Compose still adds the generated adapter container (# added by compose::add) when a project needs one, as in 0.26, at the newest release in ^0.5. Only the start order on it moves into the file, in start_after. Every 0.26 project pins sandbox-libkrun to a 0.3.x release, which lacks worker.build. In a project with a VM container, wherever the rewrite runs and before it:
  • a generated adapter container (# added by compose::add) outside ^0.5 is updated to the newest release in that range, with the lock;
  • an adapter container you declared yourself outside the range fails with SANDBOX_ADAPTER_TOO_OLD, naming the container, its range, and the command to run. Update it, or edit its version:
  • under --frozen, an adapter outside the range fails with SANDBOX_ADAPTER_TOO_OLD, after the VM_SCRIPTS_MISSING check of CI and --frozen.
A project without a VM container, which only runs ephemeral sandboxes, keeps its adapter version: 0.3.x serves those. sandbox::build and sandbox::start require worker.build and fail with SANDBOX_BUILD_UNSUPPORTED otherwise. sandbox-libkrun in legacy mode (III_ROOTFS_MODE=legacy, or a build without an embedded iii-init) does not advertise it. A binary package in a VM also needs worker.binary (SANDBOX_BINARY_UNSUPPORTED). A compose::remove that keeps the data needs worker.prune: without it, Compose leaves the VM as it is and logs where its state stays. Another adapter needs contract 1.4, as described in Sandboxes / VM workers.

Keep the data of migrated VMs

The data a 0.26 VM wrote is not deleted. The adapter keeps it beside the new disk, under ~/.iii/sandbox/workers/<vm_id>/:
  • The first worker::start with a build writes a seal file, <vm_id>/build-mode, beside root/ and out of the guest’s reach.
  • A start with a build that finds the 0.26 overlay disk, root/upper.ext4, without the seal moves it to <vm_id>/upper.ext4.pre-build (upper.ext4.pre-build.1 and so on when that name is taken). It then creates the new data disk, <vm_id>/upper.ext4, writes the seal, and logs the old disk’s path in the container’s logs and in the adapter’s log. A boot that fails after that move names the kept path in its error.
  • In a legacy-mode directory, the cloned rootfs is root/ itself. It is renamed to root.pre-build/, a fresh root/ is created, and the path is logged the same way.
The 0.26 disk mixes installed dependencies with data. Kept as the upper, it would shadow the dependencies of the build. upper.ext4.pre-build is an ext4 image, kept beside the new disk. On Linux, inspect it read-only by mounting it as root:
Nothing restores it automatically. compose::remove keeps it, with the VM’s current data disk. compose::remove prune=true removes all of it, the pre-build disk included. From then on, the VM’s data disk is independent of the build: it keeps what the worker writes across restarts, rebuilds, and a compose::remove without prune. Only compose::remove prune=true resets it.

Day-to-day changes

  • Dependencies. A run no longer installs them. Edit package.json, run iii call compose::build worker=<container>, and restart the container once it built. On each start, Compose logs a line when a dependency file or the base image changed since the last build. See Builds that are out of date.
  • Code. A path:// worker’s code keeps syncing live into the guest.
  • Package updates. compose::update that changes a package rebuilds the container before restarting it. A failed rebuild keeps the old build running, and retrying the update finishes it. See Rebuilds.
  • Project directories. Compose writes a .gitignore containing * in .iii/workers/ and in .iii/build/, so your own .gitignore needs no edit.
  • Removing a container. compose::remove stops a build of the container that is still running, deletes .iii/build/<container>/ and .iii/workers/<container>/, and has the adapter destroy the VM’s runtime state. The VM’s data stays, and the log says where. prune=true deletes it too.
  • iii compose build. It also updates or adds the generated adapter, runs the rewrite, and copies the packages into .iii/workers/. It does not run scripts.build.

Roll back

A migrated VM project no longer loads in 0.26: scripts.build is unknown there. To go back, install 0.26 and restore the compose file you committed before the upgrade, with its lock:
<commit> is the commit you made before the first run of the new release. A file that uses none of the new keys (scripts.build, scripts.run on a bundle) still loads in 0.26 as it is. Restoring the file does not bring back the data of the 0.26 VMs: it stays in upper.ext4.pre-build. See Keep the data of migrated VMs.

Error codes

The sandbox adapter adds S507, S508, and S509. Every log line Compose writes for VM workers is in Log lines.

Checklist

  • Stop the running 0.26 project
  • Commit worker-compose.yaml and worker-compose.lock before the first run of the new release
  • Upgrade iii
  • Rename container keys that start with . or hold / or \, and the start_after entries that name them
  • Declare scripts.build ("" when there is nothing to build) on each path:// worker with runtime.base_image that must stay on the host, and a host scripts.run on each bundle that must stay on the host
  • Set the version of a sandbox-libkrun container you declared yourself to "^0.5"
  • Run iii compose build, review git diff, and move back to the host any container rewritten by mistake
  • Run iii compose --up once without --frozen, then review and commit the rewritten file and lock
  • Keep --frozen in CI only after that commit: a file still due fails with VM_SCRIPTS_MISSING
  • Find the kept the pre-build data disk log lines, and keep each pre-build disk while you need it. compose::remove prune=true removes it together with the VM’s current data disk
  • After a dependency change, run iii call compose::build worker=<container>, then restart the container
  • If you run another sandbox adapter, move it to contract 1.4
  • If a script of your own read the III_SANDBOX_* variables, move it to III_CALL_DEFAULTS
For the compose file side of VM workers, see Compose / VM workers. For sandbox::build, sandbox::start, removing a VM, and the adapter contract, see Sandboxes / VM workers.