Skip to content
Kaiov0.8.0

CLI

The CLI is a thin client over the server API; it does not talk to Docker directly, so a server must be running.

KAIO_ADDR (default 127.0.0.1:8080) says which server it talks to. Point it elsewhere for one command with KAIO_ADDR=10.0.0.2:8080 kaio-cli status, or reach a node of the cluster with node <name> run. unix:/run/kaio/kaio.sock talks to a server on a Unix socket, and credentials in a URL (https://ci:$TOKEN@kaio.example.net) are sent as Basic auth on every call, the shell’s WebSocket included.

A terminal session with kaio-cli: version reports the CLI and the server, status --sort cpu --filter db lists the matching containers grouped by stack, with their state, ports, CPU, memory and traffic, stack ls shows the stacks with their state, version, pending update and CVE counts, then a compose.yml and a .env deployed as media-hub with stack deploy --wait, which answers once it is up and healthy and appears in the next stack ls. Then the versions and the merged logs of the blog stack, a dry run of copying it to prod-02 as blog-staging with a port moved and both volumes listed, image ls with the stacks using each image, the cluster nodes with the offline one explained, the stacks of prod-01 read with node prod-01 run stack ls, then whoami, the audit log and the doctor's findings, and kaio-server setup lan writing the line that lets a network in.
A stack deployed from a compose.yml and a .env, its versions and logs read back, a copy to another server planned with --dry-run, then the same commands run on a node with node <name> run, and who you are, who did what and what to fix.
Flag Effect
--json Emit machine-readable JSON instead of formatted tables
--version Print the CLI’s version and build SHA, then exit, without reaching the server
-h, --help Describe the command and its arguments; on a group, list its subcommands
Terminal window
kaio-cli status # every container, grouped by stack
kaio-cli health # health check
kaio-cli version # this CLI's version, and the server's
kaio-cli events # recent history
kaio-cli events --follow # live SSE tail
kaio-cli tui # launch the interactive TUI

status lists the containers under their stack. The stack’s own row sums the CPU, memory and network traffic of its containers, and a last line gives the totals of the containers listed, all of them or only those a filter kept, with the share of the host’s cores when the server reports them. CPU follows Docker’s scale, where 100% is one core.

Terminal window
kaio-cli status --sort cpu # heaviest stacks first, heaviest containers first inside
kaio-cli status --filter blog # stacks, containers or images whose name holds "blog"
kaio-cli status --sort cpu --filter db: one row per stack holding a container whose name or image contains db, with the stack's summed CPU, memory and traffic, the matching container indented underneath, and a last line with the totals of the matching containers and the share of the host's cores.
status --sort cpu --filter db: the stacks, their matching containers, and the totals.

--sort takes attention (the default: stacks with a container not running, an update waiting, variables pending or a critical CVE come first), name, cpu, memory, net or vulns. With --json, status keeps printing the flat list of containers, in that order and with that filter. container ls stays the flat list, one row per container, in the server’s order, for scripts that read it.

version prints the CLI’s own version first, with the git SHA it was built from in parentheses, then asks the server for its own, so a CLI left behind after an upgrade shows up as two numbers that disagree:

cli: 0.8.0 (4af081d)
server: 0.8.0

The server line reads unreachable at <addr> when nothing answers there, and version --json reports that as "server": null, with the SHA on its own sha field. A build made outside a git checkout, and without KAIO_GIT_SHA set, stamps dev instead of a SHA.

Terminal window
kaio-cli container ls
kaio-cli container start <id>
kaio-cli container stop <id>
kaio-cli container restart <id>
kaio-cli container pause <id>
kaio-cli container unpause <id>
kaio-cli container rm <id>
kaio-cli container logs <id> [--follow] [--tail <n>]
kaio-cli container shell <id> # interactive shell, Ctrl-] to exit
Terminal window
kaio-cli stack ls # state, version, update, env, CVEs, host access, external
kaio-cli stack show <name>
kaio-cli stack deploy <name> <compose_file> [--env-file .env [--secret KEY]] [--accept-risks] [--allow-port-clash] [--wait [--wait-timeout 120]] [--expected-version N] [--dry-run]
kaio-cli stack rm <name>
kaio-cli stack start <name>
kaio-cli stack pause <name>
kaio-cli stack unpause <name>
kaio-cli stack recreate <name>
kaio-cli stack update <name> [--wait [--wait-timeout 120]] [--expected-version N] [--dry-run]
kaio-cli stack restart <name> [--accept-risks]
kaio-cli stack logs <name> [--follow] [--tail <n>]
kaio-cli stack scan <name> # Trivy vulnerability scan
kaio-cli stack check-update <name>
kaio-cli stack versions <name>
kaio-cli stack rollback <name> <version> [--accept-risks] [--allow-port-clash] [--wait [--wait-timeout 120]] [--expected-version N] [--dry-run]
kaio-cli stack version-rm <name> <version>
Terminal window
kaio-cli stack copy <name> --to prod-02 # definition only, not started
kaio-cli stack copy <name> --to prod-02 --with-volumes # carry the data across
kaio-cli stack copy <name> --as web-staging # clone it here under another name
kaio-cli stack copy <name> --to prod-02 --dry-run # show the plan, change nothing
kaio-cli stack copy <name> --as web-02 --publish 8091:9091 --start
kaio-cli stack copy <name> --as web-03 --port-offset 2000 --start
kaio-cli stack copy <name> --as web-02 --env SITE_URL=https://staging.example.net
kaio-cli stack copy <name> --as web-02 --env-file staging.env
kaio-cli stack copy <name> --to prod-02 --accept-risks # its file hands the host to a service

A clone on the same host claims the ports its source already holds, so the copy is refused rather than written unusable (--allow-port-clash accepts it anyway). --publish old:new (repeatable) and --port-offset N rewrite only the ports: entries of the copy’s compose file; --env and --env-file override its variables. A port written as ${HTTP_PORT}:80 is left to the variables.

The source is never stopped, written to or removed, and a copy that fails part way is undone on the destination. --to and --from name nodes as kaio-cli node ls does; leaving one out means this server, so a copy that stays here needs a different name with --as.

Without --start the copy is written but not brought up: two live copies would contend for the same DNS, webhooks, queues and mail. --allow-binds accepts that mounted host paths stay behind, and --allow-anonymous-volumes accepts losing volumes Docker named itself. Both are refusals by default, because either one silently produces a copy that looks healthy and is missing data. A stack whose file hands the host to a service is refused as a deploy is, until --accept-risks.

See the API route for what the plan contains and what stops a copy before it starts.

Saved as pending until stack apply. See Environment variables.

Terminal window
kaio-cli stack env ls <name> # secrets are masked
kaio-cli stack env set <name> TAG=1.27 DB_PASSWORD=s3cret [--secret]
kaio-cli stack env unset <name> TAG
kaio-cli stack env import <name> .env # merge a .env file
kaio-cli stack apply <name> [--accept-risks] [--allow-port-clash] [--wait] [--expected-version N] [--dry-run] # redeploy with the pending environment

Each of these three nouns exposes the same three commands:

Terminal window
kaio-cli image ls
kaio-cli image rm <id>
kaio-cli image prune
kaio-cli volume ls
kaio-cli volume rm <name>
kaio-cli volume prune
kaio-cli network ls
kaio-cli network rm <id>
kaio-cli network prune

ls adds a STACKS column: the stacks whose containers use the image, volume or network, - when none does. volume prune removes every unused volume, named ones included, the equivalent of docker volume prune -a.

See Multiple servers.

On the control plane:

Terminal window
kaio-cli cluster token # mint a join token: one server, once, within 24 hours
kaio-cli cluster token --rotate # retire every unused token first; enrolled servers are not affected
kaio-cli cluster info # control plane? member? neither?

On the server joining it:

Terminal window
kaio-cli join <control-plane> --join-token <t> [--name <n>] [--advertise <host:port>]
kaio-cli join 10.0.0.1:8080 --token-stdin # read the token from stdin
kaio-cli cluster leave # leave: tells the control plane, then forgets

--name defaults to the joining server’s own host name; the control plane sanitises it and suffixes it if it is taken. --advertise is rarely needed: the server reports its own KAIO_ADDR, and the control plane supplies the address the request arrived from when that is a wildcard. Pass it when neither is what others reach the server at: behind NAT, or a reverse proxy.

The Kaio servers that have joined this one. See Multiple servers.

Terminal window
kaio-cli node ls # the control plane, then each node's last probe
kaio-cli node show <name>
kaio-cli node rm <name>
kaio-cli node check [<name>] # probe one node, or every node
kaio-cli node <name> run <command> # run any command on that node

node <name> run forwards through this server’s gateway, so every command works there: node prod-01 run stack ls, node prod-01 run health, even node prod-01 run tui. A node that is not in the registry has no route and answers Node '<name>' has not joined this cluster.

Names that would collide with the subcommands above (ls, show, rm, check, run, help) are never handed out: a host called run is enrolled as run-2.

Nodes enter this list by running kaio-cli join on them, and nothing here edits one: a server is the source of truth about its own address. node rm drops a member, which comes back by joining again.

Terminal window
kaio-cli whoami # who the server takes you for, and your level
kaio-cli audit # who did what, newest first
kaio-cli audit --limit 200
kaio-cli doctor # settings that leave the daemon open, and their fix

whoami answers at any level, so it is the first thing to run when a command gets 403:

user: alice
level: write
via: proxy
source: 127.0.0.1
groups: kaio-devs
kaio-cli whoami reporting regis at the admin level through the proxy, kaio-cli audit --limit 6 listing deploys, a rollback, an environment edit and two refusals with who did them, and kaio-cli doctor naming two warnings and one note with their fixes.
whoami, audit and doctor: who you are, who did what, and what to fix.

audit reads the audit log and doctor the diagnosis, both at admin. doctor adds what it sees on the CLI’s side, such as credentials in a KAIO_ADDR sent over plain HTTP, and exits with 1 when a finding is a danger:

warn proxy-without-secret
Identity headers are trusted from the proxy's address alone: anything else on that address can claim to be anyone
fix: Generate a secret with `openssl rand -hex 32`, set KAIO_PROXY_SECRET_FILE, and have the proxy send it as X-Kaio-Proxy-Secret
Terminal window
kaio-cli system prune [--volumes]

--json turns any command into a data source:

Terminal window
# Stacks with a pending update
kaio-cli --json stack ls | jq '.[] | select(.update_available) | .name'
Terminal window
# Nodes that are not answering
kaio-cli --json node ls | jq -r '.[] | select(.status != "online") | "\(.name) \(.last_error)"'

A pipeline drives these same commands over HTTP, with the published image and its entrypoint overridden: see Deploy from CI.

Kaio, built by Régis Gaidot