Self-host quickstart
Start T-agent with Docker Compose, log in, and connect your first computer.
Self-hosting T-agent has two parts:
| Part | What it runs | Where it lives |
|---|---|---|
| agentdock service | Web, API, and PostgreSQL | One machine with Docker installed |
| Computer | The agentdock daemon and AI coding tools | The computer developers actually work on |
They can be the same machine or separate ones. Self-hosting replaces only the T-agent Cloud part.
This guide uses Docker Compose. For Kubernetes deployments, see the Self-hosting guide in the repository.
The defaults use local agentdock-backend:dev and agentdock-web:dev images. Run make selfhost-build first. Use the installer or pull-based deployment only after explicitly configuring published AGENTDOCK_BACKEND_IMAGE, AGENTDOCK_WEB_IMAGE, and AGENTDOCK_IMAGE_TAG values.
Before you start
The machine running the agentdock service needs:
- Docker Engine or Docker Desktop, with
docker composeworking - Git, Make, curl, and OpenSSL
- Ports
3000and8080free on the machine
Confirm Docker and Compose are available first:
docker info
docker compose versionT-agent uses Compose v2, invoked as docker compose. The legacy docker-compose v1 is not supported.
The computer also needs at least one AI coding tool installed and logged in, such as Claude Code, Codex, or Cursor. The agentdock CLI is installed in step 5.
1. Start T-agent
Build and start the default local application images from the source checkout. This creates configuration when missing and reuses existing secrets and volumes. A published image channel is optional and must be explicitly configured.
git clone --depth 1 https://github.com/shenziggy0/T-agent.git
cd T-agent/agentdock
make selfhost-build2. Confirm the services are ready
Check container status:
docker compose -f docker-compose.selfhost.yml pspostgres should show healthy, and backend and frontend should be running. Then check the backend, the database, and migrations:
curl -fsS http://localhost:8080/readyzThe expected response is:
{"status":"ok","checks":{"db":"ok","migrations":"ok"}}The backend container runs database migrations on every startup before serving; there is no manual migration command to run.
3. Choose how to access
Local access
Open http://localhost:3000 directly. You also won't need to pass any URLs when running agentdock setup self-host later.
Remote access
Docker Compose binds 3000 and 8080 to 127.0.0.1 only. Do not switch this to 0.0.0.0 to expose the ports to the public internet; use a reverse proxy with HTTPS instead.
The example below uses two domains:
app.example.com: the T-agent web appapi.example.com: the API, health checks, and daemon connections
First set the public URLs in .env:
FRONTEND_ORIGIN=https://app.example.com
AGENTDOCK_APP_URL=https://app.example.com
AGENTDOCK_PUBLIC_URL=https://api.example.comWith this configuration all browser traffic stays on the app domain, so cookies never cross domains and COOKIE_DOMAIN is not needed. If the browser talks to the api domain directly instead, you must set it — see Environment variables.
Then set up DNS and proxy the local ports with Caddy:
app.example.com {
# Hand browser WebSockets straight to the backend
@ws path /ws /ws/*
handle @ws {
reverse_proxy 127.0.0.1:8080 {
flush_interval -1
}
}
# Everything else goes to the frontend, which forwards API and login requests
handle {
reverse_proxy 127.0.0.1:3000
}
}
api.example.com {
reverse_proxy 127.0.0.1:8080 {
flush_interval -1
}
}If you would rather serve everything on a single origin (one domain, or one host with one port — common on small servers), route the daemon-critical paths to the backend explicitly and let the frontend handle the rest:
agentdock.example.com {
# CLI reachability probe: `agentdock setup` GETs <server-url>/health and
# needs a 200 — older web releases don't forward it, so route it directly
handle /health {
reverse_proxy 127.0.0.1:8080
}
# Browser realtime WebSocket — the web image cannot proxy WS upgrades
handle /ws {
reverse_proxy 127.0.0.1:8080 {
flush_interval -1
}
}
# Daemon long-connection WebSocket: daemons dial {server-url}/api/daemon/ws
# (not /ws). Without this route the handshake fails and the daemon silently
# falls back to polling
handle /api/daemon/ws {
reverse_proxy 127.0.0.1:8080 {
flush_interval -1
}
}
# Everything else goes to the frontend, which forwards API and login requests
handle {
reverse_proxy 127.0.0.1:3000
}
}With a single origin, point both URLs at it (FRONTEND_ORIGIN and AGENTDOCK_APP_URL in .env, then --server-url and --app-url in agentdock setup self-host).
Caddy obtains TLS certificates and forwards WebSockets. After editing .env, recreate the containers with up -d so the new configuration takes effect:
docker compose -f docker-compose.selfhost.yml up -d
curl -fsS https://api.example.com/readyz
curl -fsS https://app.example.com/api/config | grep -o '"daemon_server_url":"[^"]*"'The last command prints daemon_server_url, the URL daemons use to reach the API: AGENTDOCK_DAEMON_SERVER_URL when set, then AGENTDOCK_PUBLIC_URL, otherwise the app URL — AGENTDOCK_APP_URL, falling back to FRONTEND_ORIGIN. When neither AGENTDOCK_APP_URL nor FRONTEND_ORIGIN is set, the field is omitted from the response entirely (so the grep prints nothing), even if AGENTDOCK_DAEMON_SERVER_URL or AGENTDOCK_PUBLIC_URL is set. If it prints a localhost address, .env still carries local defaults: set FRONTEND_ORIGIN and AGENTDOCK_APP_URL explicitly to the public URLs instead of relying on the ${FRONTEND_PORT} references copied from .env.example, then recreate the containers.
docker compose restart only restarts existing containers and does not re-read .env. After changing configuration, run docker compose -f docker-compose.selfhost.yml up -d to re-read .env.
4. Log in and create a workspace
Open http://localhost:3000 locally, or the https://app.example.com you just configured, and enter your email to request a verification code.
First configure your own SMTP relay or a verified Resend sender. In production the server returns HTTP 503 until email delivery is configured. Request a code, read the email, and enter the code to create your workspace. See authentication setup.
Self-hosted deployments default to APP_ENV=production, which disables fixed verification codes. Do not set AGENTDOCK_DEV_VERIFICATION_CODE on a public instance.
5. Connect a computer
Run the commands below on the computer that runs your AI coding tools, which is not necessarily the server running Docker.
Tasks run with the full permissions of the user running the daemon — they can read and write everything that user can. Run the daemon as a dedicated Unix user, in a container, or in a VM rather than under your personal account. See the security model.
Install the agentdock CLI first:
macOS / Linux
# From the source checkout; configure the published channel as described in /cli.
bash scripts/install.shWindows PowerShell
# Set AGENTDOCK_RELEASE_URL and AGENTDOCK_RELEASE_API_URL to your published channel first.
powershell -File scripts/install.ps1If the agentdock service runs on this same computer:
agentdock setup self-hostIf the agentdock service runs on another machine, pass the two URLs you configured earlier:
agentdock setup self-host \
--server-url https://api.example.com \
--app-url https://app.example.comThe command first checks <server-url>/health, then opens a browser to complete login. After login it stores local credentials and starts the daemon. A Server not reachable error at this step means the probe could not get a 200 from /health: the proxy forwards everything to a web release that does not forward the path, the proxy does not route /health to the backend at all, or a lower-level failure (DNS, TLS, firewall, timeout, 5xx from the backend) — see Troubleshooting.
Confirm the connection:
agentdock daemon statusThe output should show:
Daemon: runningAgentslisting the AI coding tools installed on this machineWorkspacesgreater than0
6. Complete the first run
Back in T-agent, once an online runtime appears in the runtime list, create an agent and assign it your first issue.
When the run shows as completed and the agent's reply appears in the timeline, the self-hosted service, the computer, and the AI coding tool are all connected. For detailed steps, see steps 3-5 of the quickstart.
Common admin commands
Run all of these from the agentdock repository directory:
# Check status
docker compose -f docker-compose.selfhost.yml ps
# Tail backend logs
docker compose -f docker-compose.selfhost.yml logs -f backend
# Apply .env changes
docker compose -f docker-compose.selfhost.yml up -d
# Stop the services, keeping the volumes
docker compose -f docker-compose.selfhost.yml downFor a local source installation, review and pull the source changes, then rebuild. For a published-channel installation, configure the intended AGENTDOCK_BACKEND_IMAGE, AGENTDOCK_WEB_IMAGE and AGENTDOCK_IMAGE_TAG before running make selfhost. Pulling source alone does not rebuild containers. Defaults are local dev tags, not a published latest channel.
git pull --ff-only
make selfhost-build
curl -fsS http://localhost:8080/readyzYour .env is not overwritten
make selfhost only generates .env when the file is missing. Re-running it on an existing install leaves your JWT_SECRET, Postgres password, email settings, and FRONTEND_ORIGIN exactly as they were.
Back up Postgres first
Migrations are forward-only, so take a dump before upgrading a deployment you care about:
docker compose -f docker-compose.selfhost.yml exec -T postgres \
pg_dump -U agentdock agentdock > agentdock-backup.sql && gzip agentdock-backup.sqlDo not pipe pg_dump straight into gzip. A shell reports the exit status of the last command in a pipeline, so pg_dump … | gzip > backup.sql.gz exits 0 even when the dump failed — leaving a perfectly valid 20-byte archive containing nothing. Redirecting to a file first makes pg_dump's own exit status the one that counts, and && only compresses a dump that actually succeeded.
Use your own POSTGRES_USER / POSTGRES_DB from .env if you changed them from the agentdock defaults. Data lives in the named volume agentdock_pgdata, which survives docker compose down — but not down -v.
Migrations run themselves
As in Step 1, the backend container runs ./migrate up on startup (docker/entrypoint.sh) before serving traffic. There is no separate upgrade command — bringing up the new image is the migration step. Watch it happen:
docker compose -f docker-compose.selfhost.yml logs -f backendMigrations run automatically when the backend starts; migrations that backfill historical data (such as 103) complete the backfill automatically too. In rare cases the automatic backfill fails with refusing to drop legacy daily rollups — see Troubleshooting.
Verify with /readyz, not /health
/health is a liveness probe — it returns {"status":"ok"} as long as the process is up, including when migrations failed. /readyz (server/cmd/server/router.go:680; /healthz is an alias) checks the database and the applied migration set, so it is the one that catches a bad upgrade:
curl -s localhost:8080/readyz
# {"status":"ok","checks":{"db":"ok","migrations":"ok"}}Anything other than HTTP 200 with both checks ok means the new version did not finish migrating — check the backend logs before sending traffic at it.
Kubernetes
The chart defaults to local dev images with pullPolicy: Never. Build and preload them on every eligible node. For a published channel, explicitly configure both image repositories, tags and pull policies in values before helm upgrade. A rollout restart alone neither builds nor downloads a new image.
Common issues
| Symptom | Check first |
|---|---|
/readyz does not return ok | Run docker compose -f docker-compose.selfhost.yml logs backend postgres. |
| No verification code arrives | Check the configured SMTP relay, authorization code and sender address. |
setup self-host reports the server is unreachable | From the computer, request https://api.example.com/health to confirm DNS, TLS, and the reverse proxy are all reachable. A 404 means the proxy sends /health to an older web release that does not forward it — route it to the backend (Troubleshooting). |
The daemon lists no Agents | Confirm the AI coding tools are on PATH and logged in, then run agentdock daemon restart. |
| Issues stay queued | Run agentdock daemon status to confirm the daemon is running and connected to the workspace. |
For more scenarios, see Troubleshooting.
Next steps
- Auth setup — configure email, Google login, and signup scope.
- Environment variables — the full server configuration reference.
- Self-hosting guide — Kubernetes, upgrades, and manual deployment.
- Desktop app — connect Desktop to a self-hosted service.