Skip to content
Kaiov0.8.0

herdr

herdr is a terminal multiplexer for coding agents: Claude Code, Codex, OpenCode and the others run in its panes, its background server keeps them working when the client detaches, and its sidebar says which one is blocked. It is meant to run on the machine where the work lives, and it publishes no container image.

This example gives it one anyway, built from the stack itself, so the agents run in a container with no Docker socket and no access to the host, and you reach them from a Kaio shell on any server of the cluster.

services:
herdr:
image: herdr-box:${HERDR_VERSION}
build:
context: .
args:
HERDR_VERSION: ${HERDR_VERSION}
dockerfile_inline: |
FROM docker.io/library/debian:bookworm-slim
ARG HERDR_VERSION
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git less procps \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL -o /usr/local/bin/herdr \
"https://github.com/herdrdev/herdr/releases/download/v$${HERDR_VERSION}/herdr-linux-$$(uname -m)" \
&& chmod +x /usr/local/bin/herdr
RUN useradd -m -u 1000 -s /bin/bash dev
USER dev
WORKDIR /home/dev
command: ["herdr", "server"]
init: true
restart: unless-stopped
environment:
- TERM=xterm-256color
- LANG=C.UTF-8
- SHELL=/bin/bash
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
volumes:
- home:/home/dev
volumes:
home:
  • The image is described by dockerfile_inline, so the stack needs no file beside its compose.yml: docker compose up builds it the first time, on whichever server the stack lands. $$ keeps a $ away from Compose interpolation for the shell inside the build. dockerfile_inline needs Docker Compose 2.17 or later.
  • The image tag carries the herdr version. Changing HERDR_VERSION names an image that does not exist yet, which is what makes the next deploy rebuild it.
  • The container’s process is the headless herdr server, so stack logs shows its startup and the stack state says whether it runs. Clients started in a shell find it on ~/.config/herdr/herdr.sock.
  • home holds everything that has to outlive the container: herdr’s ~/.config/herdr with its saved session, the agents you install and their logins, and the repositories you clone.
HERDR_VERSION=0.9.5
ANTHROPIC_API_KEY=sk-ant-...

ANTHROPIC_API_KEY is flagged as a secret and only needed if Claude Code should use an API key rather than a login.

Terminal window
kaio-cli stack deploy herdr ./compose.yml --env-file .env
kaio-cli stack logs herdr --follow

The first deploy downloads Debian and the herdr release and builds the image, so it takes longer than the next ones.

Terminal window
kaio-cli container ls
kaio-cli container shell <id>
herdr

The same shell opens from the container row in the web UI, or with ! in the TUI. On another server of the cluster, prefix the command with kaio-cli node prod-02 run.

Install an agent in a pane, clone a repository and start it:

Terminal window
curl -fsSL https://claude.ai/install.sh | bash
git clone https://github.com/you/project && cd project
claude

Two keys to tell apart: ctrl+b q detaches from herdr and leaves the agents working, Ctrl-] then leaves the Kaio shell. Run herdr again from a new shell to find them where they were.

Terminal window
kaio-cli stack env set herdr HERDR_VERSION=0.9.6
kaio-cli stack apply herdr # builds the new image, recreates the container
kaio-cli stack versions herdr
kaio-cli stack rollback herdr 1 # back to the previous herdr image

Recreating or restarting the container stops the herdr server and the processes in its panes. The server saves the session on its way down and restores the layout from ~/.config/herdr when it starts again, and agents with a herdr integration resume their conversation: see Session state and restore. Detach before an apply rather than in the middle of a task.

stack check-update and stack update compare an image with its registry, and herdr-box is built by the stack and lives in no registry, so the check leaves it out: the version in HERDR_VERSION is what moves it.

Terminal window
kaio-cli stack copy herdr --to prod-02 --with-volumes
kaio-cli node prod-02 run stack restart herdr

The home volume carries the session, the logins and the clones, and prod-02 builds the image from the same compose.yml. Stop the source first: two copies of a logged-in agent working on the same repository will step on each other.

Kaio, built by Régis Gaidot