Guide · Self-hosting
Self-hosted AI coding agent on your own server with Docker
Cloud coding agents run in someone else's sandbox. A self-hosted agent runs on a machine you control, next to your code, tools and logins. This guide explains how AgentPort does that with one Docker container, and how to set it up.
The setup in one picture
Your browser (phone, laptop, tablet)
│ secure WebSocket, direct
▼
Your server: AgentPort container ──▶ Grok Build / Antigravity
│ working in ~/agentport-workspaces
│ sign-in + "which computers are mine"
▼
AgentPort cloud (no code, no chat stream)
- Agents run on your server. The AgentPort container runs the coding agent: Grok Build or Google Antigravity.
- Browser to server is direct. Your chat goes straight to your machine. The cloud does not relay agent output.
- The cloud is a phone book. It handles accounts, the list of your computers, and short-lived connection tokens. Your machine's own key is never shown in the web app.
What stays on your machine
~/agentport-workspaces: your projects (mounted into the container as/workspaces).~/.grok: your Grok login.~/.geminiand~/.agy: your Antigravity sign-in and program.- A Docker volume (
agentport-data): the link to your account, chat sessions, and GitHub/Vercel CLI logins from Connectors.
Updates replace the container but keep all of the above, so logins, projects and chats survive.
Requirements
- A Linux server, home server or Mac with Docker installed and running. The image is published for both
linux/amd64andlinux/arm64. - A free AgentPort account.
- Your own login for the agent you want: a Grok account for Grok Build, or a Google account for Antigravity. You pay those providers directly; AgentPort does not resell model usage.
You do not need a domain, open ports or a reverse proxy for the standard install.
Option A: one-line install (recommended)
- In AgentPort, click Add machine, name it, and choose Your computer.
- Click Copy and paste the command on the server.
curl -fsSL "https://control.agentport.johnstech.in/install.sh" | bash -s -- \
--control-url "https://control.agentport.johnstech.in" \
--token "apj_…" --tunnel-token "…" --wss-url "wss://…/ws"
The script:
- Checks Docker is installed and running, and refuses to install twice on the same computer (one computer, one AgentPort) unless you pass
--replace. - Pulls
ghcr.io/johnversus/agentport-node:latestwith a simple progress bar. - Starts the container with
--restart unless-stopped, published only on127.0.0.1:8787. - Starts a
cloudflaredcontainer for this computer's managed secure link. It connects outward, so nothing listens on a public port. - Waits for the node to link to your account, then saves settings to
~/.agentport/and anupdate-node.shhelper.
Back in the browser the computer flips to ready; click Connect. Then sign in to your agent from the computer's AI Model settings: Grok uses a device code on xAI's verify page, and Antigravity uses Google sign-in.
Option B: Coolify (Docker Compose)
If you already run Coolify, you can deploy AgentPort as a compose resource and let Coolify's HTTPS domain be the public address. No install script, no tunnel.
- In AgentPort, Add machine (a new one) and open the Coolify tab.
- In Coolify, create a Docker Compose resource and paste AgentPort's compose file.
- Give the resource a domain, for example
https://desk.example.com. - Set three environment values from AgentPort:
CONTROL_URL, the one-timeJOIN_TOKEN, andPUBLIC_WSS_URL=wss://desk.example.com/ws(the resource's domain,wss, path/ws, no port). - Deploy, wait for AgentPort to say ready, then Connect.
https://desk.example.com/health should return JSON with "service":"agentport-node". If you see the Coolify login page instead, PUBLIC_WSS_URL points at the wrong host. On Coolify, update by pulling the latest image in Coolify, not with update-node.sh.Day-to-day use
- Chats: several sessions per computer, grouped by project folder, kept on disk so they survive reloads.
- Control: for Grok, choose Ask first, Auto or Always approve. Antigravity runs in Always approve because it cannot pause for a yes.
- Files and git: browse the project, preview files, and review the Changed tab with per-file diffs.
- Connectors: sign in to the official GitHub and Vercel CLIs on the server so the agent can push and deploy. Credentials stay on the server.
- Any device: the web app has a mobile layout, so you can check on a task from your phone.
Updating and removing
When a new version is published, the computer's Software tab shows Update. Or run bash ~/.agentport/update-node.sh. The updater never wipes your account link, projects, or agent logins.
To uninstall, copy the uninstall command from the computer's settings. It removes AgentPort's containers, volume, network and ~/.agentport; your project folder and agent logins stay. Then delete the computer in the app.
Is self-hosting right for you?
Choose it if you want the agent next to your real files and tools, want tasks to keep running when your laptop is closed, or do not want your code in a third-party sandbox. The trade-off is that you keep a machine running with Docker. If you already have a VPS or home server, that is usually nothing new.
Try it on your own computer
The Free plan covers 1 computer. Pro is $27/month for up to 3. You bring the AI login and pay that provider directly.