Skip to content

Deploy Kaeso on a Linux server with Docker Compose

Run Kaeso on any Linux server you rent or own, with the installer or by hand. Every step from the DNS record to the first user, email, backups of the volumes and updates, for Kaeso 0.7.0.

Published
Reading time
7 min
Author
Kaeso Team
A bright gradient of deep and pale blue, in gentle level folds

Most Kaeso installs are one Linux server with Docker. It is the path the project tests most, the one where Update in the console works, and the one every provider guide on this site builds on. This guide works for any server with a public address: a virtual server from a hosting provider, a dedicated machine, or a computer in your own rack.

At the end you have the gateway, the console, PostgreSQL, ClickHouse for request logs, Valkey, Caddy for TLS and the updater, all on one server, answering on your domain.

What you need

A serverLinux on amd64 or arm64, with at least 2 vCPUs, 4 GB of memory and 20 GB of disk (requirements (opens in a new tab)). Ubuntu 24.04 and Debian 13 are common choices
DockerDocker Engine with Compose 2.24 or newer, and Engine 25 or newer for the updater. The installer can install Docker for you
A domainA name such as kaeso.example.com whose A or AAAA record points at the server
Open portsTCP 80 and 443 from the internet for the certificate and HTTPS, UDP 443 for HTTP/3, and SSH from your own address
EmailAn SMTP server for sign-in links, invitations and alerts. Kaeso uses port 587 with STARTTLS by default. You can start without one and add it later

What it costs depends on where the server runs: a small virtual server with 2 vCPUs and 4 GB costs a few euros or dollars a month at many providers. The guides for Hetzner Cloud, OVHcloud, Scaleway and Oracle Cloud list dated prices with links to each provider's pricing page. Kaeso itself is open source under the MIT licence.

1. Point the domain at the server

Create an A record for your domain with the server's IPv4 address, and an AAAA record with its IPv6 address if it has one. Check that it resolves before you go on:

dig +short kaeso.example.com

Caddy asks Let's Encrypt for a certificate as soon as Kaeso starts, so the record should resolve first. If it doesn't yet, the installer asks whether to go on, and Caddy keeps trying until it does.

2. Open the ports

Allow TCP 22 from your own address range, TCP 80 and 443, and UDP 443. Use your provider's firewall where it has one: it filters before traffic reaches the server.

On the server itself, note that Docker writes its own packet-filter rules for the ports a container publishes, and those bypass ufw and firewalld (Docker and firewalls (opens in a new tab)). Kaeso publishes only Caddy's ports 80 and 443. PostgreSQL, ClickHouse, Valkey, the gateway and the updater sit on internal Docker networks and publish nothing.

3. Run the installer

Sign in to the server as root, or as a user that may use sudo, and download the installer. It is a plain shell script, so read it before you run it:

curl -fsSL https://kaeso.app/install.sh -o install.shless install.shsh install.sh --domain kaeso.example.com --dir /opt/kaeso --install-docker

What the installer does, in order:

  1. Without Docker, it installs Docker Engine with Docker's own script from get.docker.com (--install-docker skips the question). As a user other than root, it adds you to the docker group and asks you to sign in again and run it once more.
  2. It checks the domain's DNS record, downloads the newest stable release's compose.yaml into /opt/kaeso, and writes .env with random passwords. Only you can read the folder.
  3. It generates the master key into master-keys, readable only by the gateway's user.
  4. It turns on the updater, so Update in the console works, and starts every service with docker compose up -d --wait. The first start downloads about 2 GB of images and takes a minute or two.
  5. It waits for Caddy's certificate and prints the one-time setup link.

To install a particular release instead of the newest one, add --version 0.7.0. sh install.sh --help lists every option.

4. Create the first user

Open the link the installer printed, and create the first user. It becomes the instance admin. The link works once, for 24 hours. To print a new one while no user exists:

cd /opt/kaesodocker compose exec gateway kaeso setup-link

Then add a provider key and create an API key in the console, as the quick start (opens in a new tab) shows. Apps reach Kaeso at https://kaeso.example.com/v1.

5. Add your SMTP server

The installer starts Kaeso with KAESO_MAIL_TRANSPORT=log: emails are only written to the gateway's log, and password sign-in and the setup link still work. To send them, switch to SMTP in /opt/kaeso/.env and add your server:

cd /opt/kaesosed -i 's/^KAESO_MAIL_TRANSPORT=log$/KAESO_MAIL_TRANSPORT=smtp/' .envcat >> .env <<'EOF'KAESO_SMTP_HOST=smtp.example.comKAESO_SMTP_USER=kaesoKAESO_SMTP_PASSWORD=your-passwordKAESO_SMTP_FROM="Kaeso <kaeso@example.com>"EOFdocker compose up -d --waitdocker compose exec gateway kaeso mail test you@example.com

The last command sends a test email and prints what the SMTP server answered. Set KAESO_SMTP_USER and KAESO_SMTP_PASSWORD together, or neither for a server without authentication: since 0.7.0, a user without a password stops the gateway at startup. Some hosting providers block outgoing mail ports on new servers; the provider guides say which.

6. Keep the master key

Kaeso encrypts the provider keys it stores with the master key in /opt/kaeso/master-keys. A database backup can't be read without it. Copy it into a password manager, apart from your backups:

sudo cat /opt/kaeso/master-keys

Check the settings

Every change to .env or compose.override.yaml takes effect with docker compose up -d --wait. Before you apply one, the gateway can check it without starting and without a database:

docker compose run --rm --no-deps gateway config check

It prints The configuration is valid., or the error the gateway would stop with and how to fix it, and names any KAESO_ variable that names no setting, such as a misspelled one. Configuration (opens in a new tab) lists every setting; put your own changes to the services in compose.override.yaml, which updates never replace.

Back up the volumes

Kaeso keeps its data in Docker volumes of the Compose project kaeso:

  • kaeso_postgres
    Holds
    Users, organizations, projects, keys, encrypted provider keys, usage, audit logs
    Back up
    Yes, with pg_dump
  • kaeso_clickhouse
    Holds
    Request logs
    Back up
    If you want to keep the log history
  • kaeso_valkey
    Holds
    Counters and caches, rebuilt from PostgreSQL
    Back up
    No
  • kaeso_caddy_data
    Holds
    The certificate and Caddy's account
    Back up
    Optional; Caddy gets a new one

Dump PostgreSQL while Kaeso runs, for example from a daily cron job, and copy the dumps off the server:

cd /opt/kaesodocker compose exec -T postgres pg_dump -U kaeso -Fc kaeso > kaeso-$(date +%F).dump

Keep compose.yaml, .env and compose.override.yaml with the dumps, and master-keys somewhere else. Backups and master keys (opens in a new tab) shows how to restore a dump, how to back up ClickHouse and how to rotate the master key. A snapshot of the whole server from your provider is a good second copy, but not a replacement for dumps: a snapshot taken while PostgreSQL writes may not restore cleanly.

Update to the next release

The gateway looks for new releases every 5 minutes, and instance admins see them under Instance › Updates. Three ways to update:

  • From the console: Update to … checks the release's signatures, downloads the images, checks that the new gateway accepts your settings, and switches over in about a minute. If anything fails before the switch, nothing changes; if the new version doesn't start, the updater rolls back.
  • Automatically: choose Automatically and an update window, daily or weekly.
  • With the installer: sh install.sh --update --version 0.7.0 in /opt/kaeso checks the new compose.yaml against the release's manifest, checks your settings with the new gateway before it stops the old one, and starts the release.

Back up PostgreSQL first. Database migrations only move forward, so going back means restoring the dump (upgrades (opens in a new tab)).

From 0.6 to 0.7

0.7.0 refuses three settings that 0.6.0 accepted. Look for them in .env and compose.override.yaml before you update:

  • KAESO_KPMR_INTERVAL below 5m: set 5m or longer, or remove it.
  • KAESO_MCP_SERVERS_SYNC_INTERVAL below 1m: set 1m or longer, or remove it.
  • KAESO_SMTP_USER without KAESO_SMTP_PASSWORD: add the password, or remove the user.

An update from the console or the installer that still finds one stops before it switches anything, says which setting and how to fix it, and 0.6.0 keeps running. See How Kaeso updates itself and checks your settings and the Kaeso 0.7 article for what else changed.

What 0.7 adds for a server

  • Outgoing connections. Guardrails and webhooks call the addresses your organizations add, over HTTPS. A private address only works when guardrails.allowed_networks or webhooks.allowed_networks lists its network, so a guardrail service on the same server or LAN needs that setting (configuration (opens in a new tab)).
  • Amazon Bedrock and Azure keys are stored like any other provider key in weighted key pools; the server only needs to reach the provider's endpoint.
  • OpenTelemetry traces go to the collector in KAESO_OTEL_ENDPOINT when you set it, and /metrics stays on the gateway's loopback address.
  • Several gateways on one server: GATEWAY_REPLICAS=2 in .env runs two behind Caddy, which share hard budgets, rate limits and route cooldowns through Valkey (scaling (opens in a new tab)).

Troubleshooting

What you seeWhat to do
The browser shows no certificatedocker compose logs caddy shows Let's Encrypt's answer. Check that the DNS record points at this server and that ports 80 and 443 are open from the internet
The gateway keeps restartingdocker compose run --rm --no-deps gateway config check prints the reason
No email arrivesdocker compose exec gateway kaeso mail test you@example.com prints the SMTP server's answer. A timeout often means the provider blocks the port
ClickHouse is killed for memoryGive the server 4 GB or more, or turn request logs off (opens in a new tab); usage, limits and budgets work the same
The setup link has expireddocker compose exec gateway kaeso setup-link prints a new one while no user exists
"Kaeso is already installed on this machine"Kaeso runs once per Docker host. Run the installer in the folder it names

Troubleshooting (opens in a new tab) in the docs covers more.

What was tested

For this guide, the 0.7.0 compose.yaml was resolved with Docker Compose 2.24 and 5 with the .env the installer writes, with SMTP added, with request logs off and with the updater on. The 0.7.0 gateway checked every setting above with kaeso config check, refused the three settings 0.7.0 no longer takes, and started against PostgreSQL, ClickHouse and Valkey with /readyz ready and a setup link. During the 0.7.0 release, a fresh Debian server was installed with the 0.6.0 installer and updated to 0.7.0 from the console, with its data intact, and an install with KAESO_KPMR_INTERVAL=1m stopped that update before anything changed, as described above.

Next steps

Product names in this guide belong to their owners and are used only to name the software and services involved. Kaeso is not affiliated with or endorsed by them.

By Kaeso Team

On this page

Own the gateway.Own the record.

curl -fsSLhttps://kaeso.app/install.sh | sh