Jobs from Compose¶
Intent¶
A repo that already describes its services in Compose should be able to run
its checks on the hoard without describing them again. Transpire is the
first user: most of just check needs the Spanner emulator and Postgres,
which its docker-compose.yml already defines, and today an allmyram job
has no way to ask for them. job.Job has had Services since Plan 1, but
nothing outside the runner's tests can set it.
The callers are mostly agents, so the interface is the CLI, kept pleasant for a person (kata's CLI is the model). Behind the CLI sits a Go API shaped to be published: the CLI is a thin layer over it.
This design settles the job spec format question of the design ('Follow-up designs', kata sqg7) for jobs with services: a job's environment is described in Compose.
Goals¶
allmyram run -- just check, run in transpire, gets the emulator and Postgres it needs from transpire's own Compose files, with no allmyram configuration beyond a small Compose override file.- What the repo's Compose file says is used as written. Where allmyram needs something different, the repo redefines it in Compose, using Compose's own override rules.
- Whatever an agent or a person knows about Compose holds: merging, profiles,
${VAR}interpolation and.envbehave asnerdctl compose(anddocker compose) does. - A job's containers find each other by service name.
- A job's command starts once the services it depends on are healthy.
- The Go API describes a job, and builds one from Compose, in packages that can be published.
Non-goals¶
- Building images (
build:). The job and its services use published images. - Real networking between a job's containers. They share one pod and one localhost; see Limits.
- Secrets. Values in a job's environment travel in the job request like any other setting.
- A stable wire protocol. Client and runner versions must match (kata vqjz).
- Per-service resource limits. The job's limits cover the whole pod, as today.
- The toolchain image transpire's job needs, and the
.gitdirectorygenerate-checkneeds. Both are separate work. - Agent output conventions for the CLI as a whole (a kata-style
--agentstatus line). This design adds only--dry-run.
Anti-goals¶
- Accepting a Compose field and quietly doing something other than what Compose means by it. A field allmyram can't honour is refused when that has a direct, known effect on what runs, and otherwise warned about, as nerdctl does; only fields that mean nothing in a pod pass silently.
- An allmyram config file that repeats what the Compose file already says.
- Needing Docker on the machine that submits the job.
Constraints¶
- The runner never parses Compose. The client loads Compose and submits a
job.Job; the runner and warden see only that type, as today. - No cgo.
- A job's containers share one pod: one network namespace, one cgroup
(
--cpusand--memorybound the sum), gVisor, and the runner's egress proxy as the only way out. - The job's own container runs as the runner's uid with no capabilities and
HOME=/tmp. Services run as their image's user with containerd's default capabilities, inside gVisor (internal/warden/podspec.go). - Every image is checked against the runner's registry allowlist and must be pullable without credentials.
- A Mac runner refuses jobs with pads.
- The module path is
allmyramand everything is underinternal/today. Publication renames the module once (Gavin); the packages here are shaped for that and live outsideinternal/so the rename is all that's left.
Approaches¶
Gavin chose A.
- A.
compose-spec/compose-go/v2(chosen). It loads, merges, interpolates and applies profiles exactly asdocker compose. allmyram translates its project model intojob.Joband refuses what it doesn't support. Cost: a dozen modest dependencies (v2.17.0: YAML, JSON schema, mapstructure, logrus, go-shellwords, distribution/reference), and a long but simple list of refused fields. - B. Parse a subset of Compose ourselves. Small and explicit, but we would reimplement merging, profiles and interpolation, and every difference from Docker is a surprise someone hits later.
- C. Shell out to
docker compose config --format json. Exact semantics for no code, but every machine that submits a job would need Docker.
The reference: nerdctl compose¶
allmyram runs on containerd, so where Compose implementations differ, it
matches nerdctl compose (containerd's Docker-compatible CLI), not Docker
Compose (Gavin). Most of that comes free: nerdctl compose is built on the
same library at the same version (compose-spec/compose-go/v2 v2.17.0 in
nerdctl's go.mod), so loading, override merging, profiles and
interpolation are the same code. nerdctl compose run SERVICE also starts
the service and its dependencies, as below. Where this document says
"as docker compose does", nerdctl does the same.
Known differences, from nerdctl's source (pkg/composer) on 2026-11-30:
- Waiting on health (allmyram differs, deliberately). nerdctl honours
only
depends_onwithservice_started. It logsIgnoring: service X: depends_on: Y: condition service_healthyand starts the next container at once. The cause is that nerdctl has no daemon: its healthchecks (nerdctl ≥ 2.1.5) run from per-container systemd timers, and nothing stays around to hold a container back. Its maintainers treatservice_healthyas unimplemented, not as unwanted (nerdctl #2386). allmyram's runner is already a long-running process that owns the run, so it waits, as Docker does. For the fields both support, a Compose file that works under nerdctl works here too, and the job waits where nerdctl wouldn't. The other differences are below. CMDhealthchecks. nerdctl turns the exec form into a shell command (it stores every check asCMD-SHELL) and warns. allmyram runs the argv as written, which is what Compose means and needs no shell in the image.- Unsupported fields. nerdctl ignores fields outside its supported list
with an
Ignoring: service X: [...]warning. allmyram warns the same way, except that it refuses fields whose loss has a direct, known effect on what runs; nerdctl supports most of those, and allmyram's sandbox can't. See 'Translating a service'.
The model: allmyram run is docker compose run¶
A job is one Compose service, the job service, run with the command given
after --, plus every service it depends on. This is what docker compose
run SERVICE CMD does: it starts the target's dependencies and nothing else,
whatever profiles say. Services the job doesn't depend on are not loaded into
the job and not checked, so transpire's fake Gmail server (which has
build:) doesn't get in the way of a job that never asks for it.
For transpire, the override file is the only new configuration:
# compose.allmyram.yaml
services:
job:
image: registry.example/transpire-dev:2026-11
profiles: [allmyram] # keeps `docker compose up` from starting it
depends_on:
spanner-emulator-health: {condition: service_healthy}
postgres: {condition: service_healthy}
environment:
SPANNER_EMULATOR_HOST: spanner-emulator:9010
POSTGRES_SERVER_URL: postgresql+psycopg://transpire:transpire@postgres:5432
UV_CACHE_DIR: /cache/uv
volumes:
- uv-cache:/cache/uv
spanner-emulator:
image: gcr.io/cloud-spanner-emulator/emulator:1.5.56
volumes:
uv-cache:
x-allmyram: {pad: {scope: global, max: 10G}}
The existing spanner-emulator-health service (curl, sleep infinity, a
healthcheck against spanner-emulator:9020) works unchanged once names
resolve; that is how transpire already gets readiness for a distroless image.
Finding the Compose files¶
- With no
--compose-file, the client looks the waydocker composedoes: from the current directory upward forcompose.yaml,compose.yml,docker-compose.yamlordocker-compose.yml, plus the matching override file, using compose-go's own discovery. It stops at the repo's top level. If it finds them and acompose.allmyram.yaml(or.yml) sits beside them, that is loaded last. --compose-file FILE(repeatable) replaces discovery, in order, asdocker compose -fdoes.--no-composeskips Compose entirely.- Interpolation reads the laptop's environment and the project's
.env, as Docker does. Those values end up in the job request. - The project directory must be inside the repo, so paths Compose resolves
relative to it (
env_file) are files the client can read;env_filecontents are read on the laptop and become environment.
Choosing the job service¶
--service NAMEnames it; the default isjob.- Compose found and the job service exists: the job is that service plus its
dependencies, followed through
depends_ontransitively. - Compose found, no job service,
--imagegiven and--servicenot given: the job runs as today with no services, and the client says on stderr that it found Compose files but no service namedjob. With--servicegiven, a missing service is always refused. - Compose found, no job service, no
--image: refused, naming the service it looked for and the files it read. - No Compose: as today;
--imageis required.
On every path, the command after -- runs through the job's effective
entrypoint, as nerdctl run and nerdctl compose run do (Gavin): the job
service's entrypoint when Compose sets one, none when Compose sets it
empty, and otherwise the image's. Without Compose that is always the
image's. This changes the no-Compose path, which today replaces the image's
entrypoint with the command; images without an entrypoint, such as
golang, behave as before. The CLI reference and the how-to say so.
Flags apply on top of the job service, the way docker compose run flags do:
--image replaces its image, --env adds or replaces variables, --workdir
sets its working directory, --pad and --global-pad add pads. --cpus,
--memory and --time-limit are the pod's, as today.
Translating a service¶
Every service field is in exactly one of four lists. The lists are the contract; the reference page documents them.
Used:
| Field | Becomes |
|---|---|
image |
the container's image; checked against the allowlist |
command, entrypoint |
CRI Args and Command, with Compose's meaning: entrypoint replaces the image's entrypoint and also drops the image's default command; command replaces only the default command; with neither set the image's both apply. The job service's command is replaced by the command after --, and its entrypoint is kept, as docker compose run does. job.Job and job.Service therefore carry Entrypoint and Command separately, and both are optional values, so "unset" (keep the image's) differs from explicitly empty: entrypoint: [] or "" runs Command directly, which must then be non-empty, and a service's command: [] clears the image's default command. A plain []string with omitempty can't carry that difference. Today the warden puts Command in CRI Command, which drops the image's entrypoint. |
environment, env_file |
the container's environment; HTTP_PROXY, HTTPS_PROXY and NO_PROXY in any case are refused, since the warden sets them |
working_dir |
the container's working directory, an absolute path. For the job service it must be /workspace or under it, and becomes the relative job.Job.WorkingDir; --workdir stays relative to the repo's top level. job.Service gains WorkingDir, a clean absolute path. |
healthcheck |
the readiness check (below) |
depends_on |
which services the job needs, and when its command may start (below) |
container_name, network aliases on the default network, and hostname (with the warning below) |
extra names in the pod's hosts file. Each must be a valid hostname (RFC 1123: letters, digits, - and .); anything else is refused by service and field, and job.Validate applies the same rule to Go callers, since the names are written into /etc/hosts and NO_PROXY. |
ports (container side), expose |
the ports the service listens on, for the clash check |
volumes, named volumes only |
per-run storage, or a pad when the volume says so (below) |
profiles |
nothing: selection follows depends_on |
A field allmyram doesn't honour is refused when ignoring it has a direct,
known effect on what runs, and otherwise ignored with a warning on stderr
naming the service and field, the way nerdctl warns (Ignoring: service X:
...) (Gavin). Only fields that mean nothing in a pod are dropped without a
word.
Ignored without a warning (no meaning in a pod that lives exactly as
long as its run): the published side of ports, labels,
restart: "no", x-* fields other than x-allmyram.
Ignored with a warning (something may or may not change):
hostname: the name goes into the hosts file, but the container still reports the pod's hostname, since CRI has no per-container hostname.- any
restartpolicy other than"no": a service that exits is not restarted. mem_limit,cpus,deploy.resources: the job's pod-wide limits apply instead.tmpfs(the field, and volumes of typetmpfs): the path is ordinary per-run storage on disk, except at or under/tmp, where gVisor keeps an empty image/tmpin memory unless the image declares a volume there, and at or under one of the job's pads, where it is in the pad.init,stop_signal,stop_grace_period,logging,sysctls,ulimits,shm_size,security_opt,cap_drop,read_only.linksthat name only services (db, ordb:db): the service's name resolves anyway.scale: 1anddeploy.replicas: 1pass silently.pull_policy: missingorif_not_presentpass silently, since that is what the runner does.- any field not named in these lists, as nerdctl does with fields it doesn't know.
Refused, naming the service and field (ignoring them changes what runs in a known way):
buildwithout animageallmyram can pull.- bind mounts.
privileged,cap_add,devices: the process expects powers it won't have.network_mode,networksother than the default,pid,ipc: the containers expect namespaces arranged differently.user: the process would run as a different user.platform: the image would be another architecture's.extra_hosts: those names wouldn't resolve.linkswith an alias other than the service's name (db:database): the alias wouldn't resolve.scaleanddeploy.replicasother than 1: allmyram runs exactly one container per service, where nerdctl would run none or several.secrets,configs: the files wouldn't exist.depends_onwithcondition: service_completed_successfully: the order it promises wouldn't hold.- Compose's GPU syntax;
--gpustays a flag. - any other
pull_policy(always,never,build, a period): the runner pulls only images it lacks, so a moved tag would silently run the cached image. - a named volume mounted at or under
/workspace: the workspace mount would hide it.
Readiness¶
job.Service gains a healthcheck (test, interval, timeout, retries,
start period, start interval), depends_on with a condition per
dependency, and its extra names. job.Job gains the same depends_on and
extra names for the job's own container. ReadyTCPPort, reserved and
refused since Plan 1, is removed. depends_on: service_healthy on a service
whose healthcheck is absent or disabled (test: ["NONE"] or disable: true)
is refused; an image's own HEALTHCHECK is not read. job.Validate enforces
the same rule and also refuses dependencies on unknown names and dependency
cycles, so a job.Job built by hand in Go can't hand the warden a graph it
can't satisfy.
Service names must pass job.Validate (lowercase DNS labels, main
reserved). A Compose service name that doesn't is refused by name; Compose
allows underscores and capitals, allmyram doesn't map them.
A service whose dependents need it service_healthy must pass its
healthcheck before they start. The check runs inside that service's
container, with its image's binaries (pg_isready is in Postgres's image,
not the job's), and only something with containerd access can run a
command in another container. So the warden does the one part only it can,
and the runner does the rest; the warden stays small (see the principles):
- The warden's Create pulls every image, starts the pod and the containers
that need no waiting (those whose dependencies are all
service_started), in dependency order, and stops there. It gains two narrow operations: run a service's healthcheck command in that service's container (CRIExecSync, with a timeout), and start one more container, a service or the job's own. The healthcheck command comes from the job's description and runs inside gVisor, so the warden grants nothing the job doesn't already have. - The runner is the waiter. It owns the timing and the rules, and asks the
warden to run each check:
CMDruns the argv,CMD-SHELLruns it under/bin/sh -c,NONEdisables the check, interval, timeout, retries, start period and start interval follow Compose, with Docker's defaults for unset timings. When the job's own dependencies are satisfied, it asks the warden to start the job's container. Nothing inside the sandbox can start the job's container early. service_startedwaits only for the container to start. Services that depend on other services withservice_healthystart once those pass, through the same start operation.- A run can end while its job's container is being started (its time limit fires, say), so the runner can't tell from its own calls whether the job ran. The warden's Stop says, from what containerd reports before it removes the pod: the job's container started only if containerd gives it a start time, so one whose start failed or never finished did not. With the pod already gone (as after a Stop whose answer was lost), or when containerd can't say within 5 seconds, the warden can't tell. Only a run whose job the warden saw start publishes its pads: when it can't tell, nothing is published and each writable pad says so, since publishing a job that never ran could replace a pad's last version with an empty one.
Waiting is the largest deliberate difference from nerdctl compose (see 'The reference: nerdctl compose').
The job's command starts when its own dependencies are satisfied and every service has started, so services always start before the job's container, as today.
Today the runner answers a submit only once the run has started
(Runner.Submit waits on the warden's Create), so a client has no run ID
until then. Waiting for services can take minutes, so that changes: the
runner answers with the run ID once Create returns (images pulled, the pod
up, and the containers that need no waiting started), and the run then
moves through a new state, waiting for services, before it is running.
Services still start first and the job's container last; only the moment
of the answer moves. During the wait, one Ctrl-C, allmyram cancel and
allmyram status all work, and the time limit is already running (it
starts when the runner answers). allmyram status reports the services
still being waited for, in a new field the CLI reference documents. A job
without services passes through the new state at once. A service that
exits, or fails its check retries times after its start period, ends the
run with a start failure that names the service and gives the last check's
output and the tail of the service's log, both capped (a few KiB each, well
inside the warden's and SSH channel's message limits). When the check
can't be run at all (no such binary in the image), the detail says that in
allmyram's words rather than passing on runsc's error text.
A dependency whose healthcheck can't run in its image (no shell for
CMD-SHELL, no curl) fails that way too; the fix is the repo's, in
Compose, as transpire's health sidecar already shows.
Names¶
The warden writes a hosts file for each run and mounts it read-only at
/etc/hosts in every container of the pod, as the kubelet does. It maps
localhost, the pod's hostname, and every service's name, hostname, container_name
and aliases to 127.0.0.1 and ::1.
Every container in the pod, services included, gets HTTP_PROXY and
HTTPS_PROXY pointing at the runner's proxy, and a NO_PROXY listing
localhost, 127.0.0.1, ::1, the pod's hostname and all of those names.
Today only the job's own container gets them, so a service that needs the
internet while starting has no way out, and a health sidecar that set a
proxy itself would send its checks of spanner-emulator:9020 to the proxy.
Limits of one shared localhost¶
- Two containers can't listen on one port. The client refuses a job whose
declared ports (
portscontainer side andexpose, by protocol) overlap, naming both services. Clashes on undeclared ports show up as a start failure. - Services and the job share the job's memory and CPU limits. The default
4 GiB will be too little for transpire's check; the job sets
--memory. - Real networking between containers (a pod per service, experiment 6) is possible later and nothing here rules it out. If it comes, it is built from CNI plugins (Gavin), as nerdctl compose's networks are, alongside the CNI egress network every pod is on today.
Volumes and pads¶
A named volume that isn't a pad is per-run storage: the path in that one
container's own filesystem, on disk, gone with the run. It starts with
whatever the image has at that path, as a new Docker named volume does.
This lets transpire's postgres-data and spanner-omni-data volumes stand
unchanged. A non-pad volume mounted by more than one selected container is
refused for now; sharing one needs a mount both containers see, which is
left open.
Per-run storage has to be on disk. A job's writes are expected to outgrow
what memory can spare (a test database, build output), and memory-backed
storage would count against the job's memory limit. gVisor can keep a
container's root filesystem overlay, where its writes land, either in
sandbox memory or in a file on the host (runsc's --overlay2 setting). In
file mode runsc creates the file beside the container's root filesystem
and deletes it with the container, so the unprivileged warden never has to
remove files a service wrote as its own user, and the file is sparse, so a
job takes disk only as it writes. Runners use that file mode. Which mode
they use today, and how one job's share of disk is bounded, is experiment
4's to find out; failing a per-file cap, the bound is the runner's
free-space floor (kata xtb5).
A volume becomes a pad when the top-level volume says so:
The pad's name is the volume's name. ro is the mount's own Compose option
(uv-cache:/cache/uv:ro). fresh is a one-off, so it stays on the command
line: a --pad or --global-pad naming a Compose pad merges onto it for
this run. Options given on the command line win, the rest keep their
Compose values, so --global-pad uv-cache:/cache/uv:fresh keeps
max: 10G. The flag's scope must match the Compose pad's; a mismatch is
refused. Pads are mounted only into
the job service; a pad volume used by another service is refused. A Mac
runner refuses pads, as today.
--dry-run¶
allmyram run --dry-run [flags] -- CMD loads Compose, applies the flags,
validates, and prints the resolved job.Job as JSON on stdout without
contacting a runner, so --runner is optional with it. It is how an agent or a person sees what their Compose
files became, and the tests' main surface for the translation.
The Go API¶
internal/jobmoves tojob/, outsideinternal/, and is documented as a public package:Job,Service,Healthcheck,Pad,LimitsandValidate. Its JSON form stays the wire form.job/composeholds the loader, sojobitself stays free of compose-go:
// Load builds the job for service from the Compose files opts finds or
// names, with command as the job service's command.
func Load(ctx context.Context, opts Options) (job.Job, error)
type Options struct {
Dir string // where discovery starts; the client's working directory
RepoTop string // discovery stops here
Files []string // replaces discovery when set
Service string // default "job"
Command []string
Env map[string]string // interpolation environment; nil means os.Environ
}
Refusals are a typed error listing every problem found, so a caller sees
all of them at once. Load distinguishes "no Compose files" (a sentinel
error the CLI treats as --no-compose) from "no such service". It
refuses, in the same typed error and naming the Compose field, everything
Validate would refuse in what the Compose files supply, but it does not
validate the job: the CLI applies its flags first (limits come from
flags, and --image, --entrypoint and --workdir may replace the job
service's), then calls Validate. Every service in the files must set
image: or build: (a provider: service needs neither), as nerdctl
compose and Docker Compose require; compose-go refuses the file
otherwise, and Load rewords that refusal to name the service. Every
selected service, the job service included, must also set image:, since
allmyram doesn't build; a build-only service nothing selects is fine.
- The CLI's run calls compose.Load, applies its flags to the result and
submits it. Submitting and attaching from Go stay in internal/client for
now.
Experiments first¶
Before the plan's code tasks, on smaug and in the Mac runner's VM, through the warden's CRI path:
- A mount at
/etc/hostsin the container config replaces containerd's default under runsc, and names in it resolve for glibc and musl images. ExecSyncruns a healthcheck in a service container under runsc, with a timeout that works.postgres:18and the Spanner emulator start in one pod under runsc as services, with a named volume's path writable in Postgres's image, and transpire'sscripts-testreaches Postgres by name.- Which
--overlay2medium runsc uses today under the runner's containerd, on smaug and in the Mac VM (where job data sits on its own XFS disk). With file-backed overlays configured, a container that writes a few GiB grows a file on the host and not the job's memory, the file is gone after the run is removed, and nothing is left that the warden can't delete. Also find whether runsc can cap the file's size per container.
The experiments gate the tasks that depend on them. If one fails, the plan
stops there and the design comes back to Gavin. The fallbacks in view:
for names, the job's environment uses localhost and service names don't
resolve (Compose files that rely on names need an override); for
readiness, the healthcheck runs in a small probe container the warden adds
to the pod instead of in the service's own.
Changes to other documents¶
- Design doc, 'Follow-up designs': the job spec format points here.
docs/how-to/run-a-job.mdgains a section on jobs with Compose services.docs/reference/cli.mddocuments the newrunflags.- A new reference page lists the Compose fields that are used, ignored, ignored with a warning, and refused.
docs/explanation/how-allmyram-runs.md: services share the pod's localhost, readiness, and the hosts file.
Left to the builder¶
- The shape of the warden's two new operations on its socket, and how the runner's records and Reconcile handle a run that was waiting for services when the runner restarted, within the rules above.
- The exact discovery calls in compose-go, and how its errors are reworded into allmyram's.
- Whether service logs reach the client during a run; today each service
writes
<name>.logbeside the job's.
Left open¶
build:: building images on a runner, or with a registry the runner can pull from.- Named volumes shared by several containers of one job.
- Bind mounts of paths inside the repo (transpire's fake Gmail server mounts test fixtures).
- Secrets, and credentials for private registries.
service_completed_successfully, for one-shot setup services.- Per-service limits.
- Real networking between a job's containers, through CNI plugins.