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::buildasks the sandbox adapter to build an image of the worker, locally, and leaves it in<project>/.iii/build/<container>/.iii call sandbox::startboots that image.worker=is the container’s own key. Moving a worker between a VM, the host, and Docker is an edit ofscripts. - 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 instart_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 withSANDBOX_ADAPTER_TOO_OLDuntil 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 forprune. - Binary packages can run in a VM. A container that sets
runtime.base_imageruns the package’s Linux build in a VM, and a binary package on the host may setscripts.
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-libkrun0.5 release (^0.5), the releases withworker.build,worker.binary, andworker.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 whosescripts.runisiii call sandbox::startfails withSANDBOX_UNSUPPORTED_PLATFORM.
Commit the compose file first
The rewrite editsworker-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
-
Stop the running project:
Ctrl^Coniii compose --up, oriii call compose::stop. -
Commit
worker-compose.yamlandworker-compose.lock, as in Commit the compose file first. - Upgrade iii.
-
Rename any container key that starts with
.or holds/or\, and thestart_afterentries that name it, as in Compatibility. For each container that must stay on the host, edit itsscriptsas in Keep a worker on the host. The rules are in How Compose rewrites a container. -
If you declared the
sandbox-libkruncontainer yourself (it has no# added by compose::addcomment), set itsversionto"^0.5". Compose updates a generated adapter container itself. See Update the sandbox adapter. -
Preview the rewrite.
iii compose buildneeds 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 runscripts.build:Move a container that was rewritten by mistake back to the host, as in Move a container back to the host. -
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. -
Review the changes to
worker-compose.yamlandworker-compose.lock, and commit them:
If you already run Run both in the project directory: the daemon resolves
iii and iii compose separately, compose::validate lists the containers
the next up rewrites, without editing the file: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.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 onscripts alone. The lock format does not
change. Compose rewrites:
- a
bundlepackage withoutscripts.run(0.26 refusedscripts.runon packages); - a
path://whose manifest setsruntime.base_imageand that has noscripts.build(0.26 refused the key), whatever itsscripts.run: none, or a command; - any container whose
scripts.runisiii call sandbox::startand that lacksscripts.buildor the adapter instart_after. Compose adds only those pieces.
- 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 ascripts.runthat 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.
scripts.run, before and after:
scripts.run command, Compose also logs a warning:
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 firstiii 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:
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, setscripts.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.5is 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 itsversion: -
under
--frozen, an adapter outside the range fails withSANDBOX_ADAPTER_TOO_OLD, after theVM_SCRIPTS_MISSINGcheck of CI and--frozen.
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::startwith a build writes a seal file,<vm_id>/build-mode, besideroot/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.1and 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 toroot.pre-build/, a freshroot/is created, and the path is logged the same way.
upper.ext4.pre-build is an ext4 image, kept beside the new disk. On Linux, inspect it read-only by
mounting it as root:
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, runiii 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::updatethat 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
.gitignorecontaining*in.iii/workers/and in.iii/build/, so your own.gitignoreneeds no edit. - Removing a container.
compose::removestops 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=truedeletes 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 runscripts.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.yamlandworker-compose.lockbefore the first run of the new release - Upgrade iii
- Rename container keys that start with
.or hold/or\, and thestart_afterentries that name them - Declare
scripts.build(""when there is nothing to build) on eachpath://worker withruntime.base_imagethat must stay on the host, and a hostscripts.runon each bundle that must stay on the host - Set the
versionof asandbox-libkruncontainer you declared yourself to"^0.5" - Run
iii compose build, reviewgit diff, and move back to the host any container rewritten by mistake - Run
iii compose --uponce without--frozen, then review and commit the rewritten file and lock - Keep
--frozenin CI only after that commit: a file still due fails withVM_SCRIPTS_MISSING - Find the
kept the pre-build data disklog lines, and keep each pre-build disk while you need it.compose::remove prune=trueremoves 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 toIII_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.