Computer Controller
The computer-controller runs one isolated Computer container per Hrida AI Studio user.
- It starts each Computer on the user's first task and stops it when idle.
- It routes Studio's requests to that user's Computer.
- It is the only component with access to the Docker socket.
- Studio is its only client.
For what users see and how to set it up in Studio, see Computer in Hrida AI Studio.
Deploy
The deployment file is hrida-helm-charts/docker/computer/docker-compose-computer-controller-prod.yaml. It runs two services:
| Service | Image | Role |
|---|---|---|
computer-controller | ghcr.io/hrida-ai/computer-controller | Starts, stops and routes the per-user Computers. |
computer-egress | ghcr.io/hrida-ai/computer-egress | The Computers' only way to the web (Squid). |
The per-user Computers (ghcr.io/hrida-ai/computer) are not in the file: the controller creates them.
Before the first start:
-
Address pools. Each user's Computer gets its own Docker network, so give Docker enough address space in
/etc/docker/daemon.json, then restart Docker. This gives 4096 networks:json{ "default-address-pools": [{ "base": "10.200.0.0/16", "size": 28 }] } -
The controller key. Create it, then keep
chmod 600on the file:bashmkdir -p secrets && openssl rand -hex 32 > secrets/controller_api_key && chmod 600 secrets/controller_api_key -
The network Studio uses to reach the controller (
COMPUTER_MGMT_NETWORK):- Studio as a Docker Swarm stack: the controller joins Studio's overlay,
hrida-studio-overlay, which must be attachable. Check withdocker network inspect hrida-studio-overlay -f '{{.Attachable}}'. Run the file on the Swarm node where the Computers should run. - Studio as plain Docker Compose: run
docker network create computer-mgmt, setCOMPUTER_MGMT_NETWORK=computer-mgmt, and add the network to the Studio service. - Never publish the controller's port on a public address.
- Studio as a Docker Swarm stack: the controller joins Studio's overlay,
-
Start it:
bashdocker compose -f docker-compose-computer-controller-prod.yaml up -d -
In Studio, open Admin › Settings › Integrations › Computer and set:
- Controller URL:
http://computer-controller:8080; - the key from step 2;
- the Studio URL Computers use, and the agent's model.
- Controller URL:
Isolation
| What each user's Computer gets | |
|---|---|
| Files | Its own container and two volumes: the workspace and app data (/data), and the home folder. Nothing is shared between users, and both are kept until the Computer is deleted with its files. |
| Network | Its own internal network with no route out. Only the controller and the egress proxy are attached. The controller listens only on its management address, so Computers can't connect to it. |
| Web | Only through computer-egress. It refuses private, loopback, link-local (including 169.254.169.254), CGNAT and multicast addresses, allows only ports 80 and 443, and logs every request. |
| Process | Non-root, a read-only root filesystem, no Linux capabilities, no-new-privileges, and a process limit. |
| Resources | CPU and memory limits, a disk quota over both volumes, and a cap on how many Computers run at once. |
| Secrets | Two files in its own volume, never environment variables: its gateway key (derived, so nothing is stored), and the user's scoped Studio token. That token works on Studio's model API only. |
Settings
The controller reads its settings from the environment.
| Variable | Default | |
|---|---|---|
CONTROLLER_API_KEY / CONTROLLER_API_KEY_FILE | required | Studio's key for the controller. |
CONTROLLER_KEY_SECRET / _FILE | the API key | Derives each Computer's gateway key. Set a separate value to rotate the two independently. |
CONTROLLER_BIND | the startup address | 0.0.0.0 to listen on every network. |
COMPUTER_IMAGE | ghcr.io/hrida-ai/computer:latest | Pulled when missing, and pre-pulled at start. |
COMPUTER_NETWORK_MODE | per-user | shared puts everyone on one network (COMPUTER_NETWORK); Computers can then reach each other. |
COMPUTER_ATTACH_CONTAINERS | — | The controller's and the proxy's container names, attached to every user's network. |
COMPUTER_EGRESS_PROXY | — | For example http://computer-egress:3128. |
COMPUTER_CPUS / COMPUTER_MAX_CPUS | 1 / 4 | Studio's per-Computer value is capped at the maximum. |
COMPUTER_MEMORY | 2g | No swap beyond it. |
COMPUTER_PIDS_LIMIT | 512 | |
COMPUTER_DISK_QUOTA_MB | 5120 | A Computer over quota gets no new work. Its owner can still open it to delete files. |
COMPUTER_IDLE_TIMEOUT_MINUTES | 30 | Idle Computers stop; their files stay. Only real use counts: tasks, and in an opened Computer its pages, file actions and terminal typing. A tab left open does not. |
COMPUTER_MAX_RUNNING | 20 | Starts beyond this answer "busy". |
COMPUTER_START_TIMEOUT_SECONDS | 120 | |
COMPUTER_TZ | — | Time zone inside the Computers. |
COMPUTER_UI_PORT | 8090 | The address people open their own Computer at. 0 turns it off. |
COMPUTER_UI_PUBLIC_URL | — | That address as people reach it, for example https://desk.computer.example.com. Studio's Address for users is the same value. With https, its cookies are secure-only. |
COMPUTER_UI_SESSION_HOURS | 12 | How long an opened Computer stays signed in. |
COMPUTER_UI_BIND | 0.0.0.0 | Where that address listens. Clients on a Computer network are refused. |
EGRESS_ALLOW_INTERNAL_HOSTS (egress) | — | Host names the Computers may reach although they are private, for example Studio's internal name. |
API
Every route except /health needs Authorization: Bearer <CONTROLLER_API_KEY>.
| Route | |
|---|---|
GET /health | Liveness. |
GET /v1/workspaces[?disk=true] | Every Computer: owner, status, disk use, idle time, over quota. |
GET /v1/workspaces/{user_id} | One Computer. |
POST /v1/workspaces/{user_id}/ensure | Create or start it, and wait until it is ready. |
POST /v1/workspaces/{user_id}/stop | Stop it; the files stay. |
DELETE /v1/workspaces/{user_id}?purge=true | Remove it, and with purge its files. |
ANY /w/{user_id}/v1/{path} | That user's Computer gateway, streamed. Only /v1/* is proxied. |
Open My Computer
Besides its API for Studio, the controller has a second address, for people: there each person opens their own Computer's file browser and terminal (see Computer in Studio › Open Your Computer).
- How someone gets in. Studio starts the person's Computer and hands them a link that works once, for a minute. The controller then signs them in to that Computer only, for
COMPUTER_UI_SESSION_HOURS. Its sessions can reach no other Computer and not the Computers' API. - When a session ends. After
COMPUTER_UI_SESSION_HOURS, when the person signs out of their Computer, when Studio stops or deletes that Computer (for example because the person lost access), and when the controller restarts. - What Studio decides. Its settings say whether the terminal is available (Terminal in Open my Computer) and whether admins may open users' Computers (Admins may open users' Computers). The controller enforces what the link says.
- Other sites can't act for a signed-in person. Changes and WebSocket connections from other sites are refused, and other sites can't frame its pages.
- Every visit is logged. The controller's log records each opening (whose Computer, which admin if any, whether the terminal is on, the client address) and each terminal session.
- Publish it on the host only. The production compose file publishes it on
127.0.0.1:8090. - Serve it on its own host name, for example
desk.computer.example.com. The proxy in front (nginx) must:- forward to
127.0.0.1:8090, passing the original host name on; - pass WebSocket upgrades (the terminal uses them) and allow long-running connections;
- allow uploads as large as your users need.
- forward to
- Use HTTPS, and set
COMPUTER_UI_PUBLIC_URLand Studio's Address for users to it. - Never share Studio's host name. On a separate host name, a Computer's pages can never read Studio's sign-in.
Operations
| Task | How |
|---|---|
| See all Computers | Studio's Show users' Computers, or docker ps --filter label=io.hrida.computer. |
| Logs | docker logs computer-controller, docker logs computer-egress (every web request), docker logs cptr-u-<hash>. |
| Upgrade Computers | Change COMPUTER_IMAGE, or pull a new latest. Running Computers switch at their next start, so no task is cut off. |
| Free a user's disk | The user can open their Computer and delete files, even over the quota. Or delete their Computer in Studio: it is created again, empty, on their next task. |
| See who opened which Computer | Studio's audit log (Admin › Trust › Audit, action OPEN), and the ui open lines in docker logs computer-controller. |
| See a user's files without Studio | Their two volumes are labelled with their Studio user id: docker volume ls --filter label=io.hrida.computer.user=<user id> lists cptr-data-<hash> (workspace) and cptr-home-<hash> (home folder). Read them with a throwaway container that mounts them read-only. |
| A user leaves | Deleting them in Studio (admin UI or SCIM) removes their Computer, its files and its token. |