Adding a second machine
This is the arrangement worth setting up early: the controller on your own machine, the agents somewhere you do not mind breaking.
The recommended setup
Section titled “The recommended setup”pm worker --sandbox --dir ~/src/acmeThat starts a container, runs an ordinary worker inside it, enrolls it with the
controller, and mounts ~/src/acme into it at the same absolute path. The
controller dispatches sessions onto it and the terminals stream back exactly as
local ones do.
The command returns once the container is up, and prints how to reach it:
pm-worker-default is running in docker.
logs docker logs -f pm-worker-default stop docker stop pm-worker-default start docker start pm-worker-default change pm worker modify --name default … apply pm worker restart --name defaultThe container runtime keeps the worker running from there, through a crash or a
host reboot, until you stop it. --foreground stays attached to its output
instead, and --restart no leaves nothing supervising it.
Manage → Workers shows a container worker as docker:pm-worker-default.
The shared directory is the whole trick. A bare --dir <path> mounts at the
identical absolute path, which is what lets a session spawned in that project
resolve its working directory on either side — so the agent edits files in the
container and your editor, your git and your tooling on the outside are looking
at the same files.
Runtimes
Section titled “Runtimes”Incus, Docker or Podman, whichever the launcher can actually talk to. On Linux it tries Incus first, then Docker, then Podman; elsewhere Docker then Podman, because Incus has no macOS host support.
On Incus it runs a system container, with
systemd as PID 1 and nesting enabled, so an agent inside it can install and run
Docker, including docker build. The OCI image used by Docker and Podman ships
no container runtime at all, so an agent inside one of those cannot.
Limits
Section titled “Limits”pm worker --sandbox --dir ~/src/acme --cpu 4 --memory 8GiB--cpu, --memory, --memory-swap, and on Incus --cpu-allowance.
Filesystem isolation
Section titled “Filesystem isolation”The container has its own filesystem and can access the host directories you
share with --dir. Repeat --dir to share multiple directories. Agents also
have access to files, credentials, and networking configured inside the container.
Your agent credential directories are not mounted by default. Pass them
explicitly with --env or an additional --dir if a session needs them.
Changing a worker after you start it
Section titled “Changing a worker after you start it”A worker’s settings are stored under its name. pm worker brings it back the
way you set it up, and adding a directory later is two commands:
pm worker listpm worker modify --add-dir ~/src/otherpm worker restartmodify writes the setting and restart rebuilds the container on it. The
rebuild ends the agents running there and resumes them with their history.
--add-dir and --rm-dir adjust the mounted directories and --dir replaces
the list. The flags that start a worker set its other settings too: --restart,
--network, --image, --cpu, --memory.
A setting passed to pm worker itself is refused once the worker is configured,
and names the modify that sets it. Enrolling is the exception: a first run
carries everything, and so does a re-enrollment that passes --controller and
--token together.
Incus home volumes use on-disk ownership mapping by default and do not require idmapped mounts. To enable mount-time ID shifting, use a host whose kernel and storage filesystem support idmapped mounts:
pm worker modify --name build --incus-shifted-homepm worker restart --name buildYou can also pass --incus-shifted-home when first enrolling an Incus worker.
The setting is saved in its profile. To disable it, pass
--incus-shifted-home=false to modify and restart the worker. Profiles without
this setting default to disabled shifting. Rebuilding a worker or running
pm worker --name build for a stopped worker applies the setting to its existing
home volume and preserves its contents. Running containers keep their current
mount until restarted. Enabled shifting fails at startup when the host lacks
support, and Docker and Podman reject the enabled option.
pm worker stop, start and logs reach the container without using Docker
or Incus directly.
Delete a worker
Section titled “Delete a worker”pm worker delete --name buildThe command describes what it will remove and asks for confirmation. It deletes the local configuration and enrollment, stops and removes the container, and removes its persistent home volume, including agent state. Shared images and bind-mounted host directories are kept. A worker running directly on the machine loses only its local configuration and enrollment. Its process and files are kept.
Pass --no-delete-resources to keep a container and its persistent agent state.
For a script, add --accept-delete to accept deletion without a prompt. Without
that flag, deletion requires a terminal. If resource cleanup fails, the local
configuration is kept so you can retry.
A whole other machine
Section titled “A whole other machine”Manage → Workers mints a single-use, short-lived token and shows the exact command for the connection direction you choose.
# the worker dials the controller — the usual case, including behind NATpm worker --controller <url> --token <enrollment>
# the controller dials the worker, for a machine that cannot open outboundpm worker --listen <host:port> --token <enrollment>The controller must be reachable at the address the worker is given, which is the
worker plane’s listener — --worker-listen, 127.0.0.1:7677 by default — and not
the dashboard’s. A controller serving remote workers has to bind that somewhere
the workers can route to.
For a listening worker, --allow-from restricts which addresses or CIDR ranges
the controller may be accepted from.
Naming, and several workers on one machine
Section titled “Naming, and several workers on one machine”pm worker --name build --controller <url> --token <enrollment>Each name enrolls separately with its own key, so one machine can join as several
workers. A bare pm worker --name build later reconnects that one, and the name
is also the container’s: pm-worker-build.
With one worker configured on a machine, every pm worker command means that
one and --name is optional. With several, a command without --name lists
them and asks which.
Telling a project where it lives
Section titled “Telling a project where it lives”A project carries a path per worker. In Manage → Projects, tick the new worker under the project’s allowed workers and give it the path the checkout sits at there — the directory picker browses that worker rather than your own machine. Leave the path unset and a spawn onto that worker is refused rather than guessed.
A spawn is also refused when the configured path does not exist on that worker, or when the worker is offline. All three refusals name the valid choices rather than failing vaguely.
Running a session on it
Section titled “Running a session on it”Nothing new: spawn from the + as usual and set the worker chip. Only workers the project is configured for are offered, and leaving the chip alone uses the project’s own default.
A project with one worker and a bucket with one worker both mean you never touch the chip at all.
Keeping it up to date
Section titled “Keeping it up to date”A worker follows its controller’s build rather than the newest published one, because the two ends have to agree on the protocol to talk at all. Updates apply when a worker has no terminals running, unless an operator forces one — which ends the agents on that worker.