_desktopdocs
guide

Docker Setup

Compose anatomy, lifecycle commands, environment variables, and running multiple computers.

Use the named launcher to start multiple desktops or manage containers directly with Docker Compose.

Prerequisites

  • Docker with Compose v2 (Docker Desktop includes both)
  • Enough Docker memory for your workload (the default per-desktop cap is 3 GB)

Lifecycle

The checked-in Compose file publishes both ports on all interfaces with credentials unset by default. See Self-hosting and security for loopback bindings and authentication before starting it on a shared network or server.

bash
docker compose up -d --build   # build + start (first boot builds the image)
docker compose down            # stop and remove container (image kept)
docker compose logs -f         # watch the boot: Xvfb → XFCE → x11vnc → websockify → daemon
docker compose ps

First build takes a few minutes; every start after that is seconds. Wait for healthy in docker compose ps, then open http://localhost:6080/vnc.html.

Reset semantics

  • ./workspace on your host persists across restarts and rebuilds — it's mounted at /workspace in the container.
  • Everything else (installed packages, desktop state, window layout) is disposable:
bash
docker compose down && docker compose up -d    # fresh computer, same files

The container also restarts itself (restart: unless-stopped) if any part of the desktop stack dies — the entrypoint exits on purpose so tini/compose can bring the whole box back up cleanly.

Configure a desktop

Set these environment variables before docker compose up -d --build, or put them in a .env file beside docker-compose.yml (see .env.example).

VariableDefaultPurpose
DESKTOP_NAMEdefaultName reported to the agent; use a unique name per desktop
DESKTOP_TOKENunsetRequire a bearer token for API access
DESKTOP_VNC_PASSWORDunsetnoVNC password of eight characters (letters, digits, + or -)
DESKTOP_MEMORY_LIMIT3gMaximum container memory, for example 4g or 2048m
DESKTOP_CPUS2Maximum CPU time in cores; fractional values such as 1.5 are allowed
DESKTOP_API_PORT8095Host port for the daemon
DESKTOP_VNC_PORT6080Host port for the viewer
DESKTOP_WORKSPACE./workspaceHost directory mounted at /workspace
GH_TOKENemptyGit auth and GitHub API access inside the container
GIT_AUTHOR_NAME / GIT_AUTHOR_EMAILeve-agent / eve@agent.localCommit identity
GIT_COMMITTER_NAME / GIT_COMMITTER_EMAILsame as authorCommit identity

The memory setting is a cap, not an allocation or a guarantee. Total host RAM is determined by the machine and, with Docker Desktop, its configured resource limits. Choose caps that fit the available Docker resources; running several desktops requires enough resources for their combined workload. Use docker compose ps and docker stats to inspect running containers.

To change a desktop's settings, update the environment and run docker compose up -d again with the same project name. Compose recreates the container when its configuration changes; files in the mounted workspace persist.

Run multiple computers

Run the launcher from the checkout with Docker and Node.js 20 or newer.

sh
node desktop-cli.mjs new --name research --api-port 8095 --cpus 2 --memory 3g
node desktop-cli.mjs new --name coding --api-port 8096 --cpus 1.5 --memory 4g

Docker assigns free localhost ports when you omit --api-port or --vnc-port. The launcher builds the image on first use and reuses it for later launches. Add --build after changing the image or daemon. Each desktop gets a bind-mounted workspace at .desktop-workspaces/<name> by default. Use --workspace to choose another host directory. Desktop commands run as root inside the container, so package installation and other administrative work can run directly.

Use the API token printed at launch, or provide a different token per desktop via --token or DESKTOP_TOKEN. Open the printed noVNC URL and enter the separate viewer password. The SDK connects using the published API port and token.

ts
import { Desktop } from "computer-use-sdk";

const research = new Desktop({ port: 8095, token: process.env.RESEARCH_TOKEN });
const coding = new Desktop({ port: 8096, token: process.env.CODING_TOKEN });
console.log(await research.cmd("whoami"));
sh
docker logs desktop-research
docker stop desktop-research
docker start desktop-research
docker port desktop-research
docker rm -f desktop-research  # remove the container and keep its workspace

With Compose, give each desktop its own -p project name and set DESKTOP_NAME, DESKTOP_API_PORT, DESKTOP_VNC_PORT and DESKTOP_WORKSPACE per project. Set DESKTOP_TOKEN for API authentication and DESKTOP_VNC_PASSWORD to allow viewer connections from outside the container when a token is set.

Give each agent the API URL and token for its assigned desktop. Use GET /api/identity to check the name and GET / for agent instructions. Open the launcher's noVNC URLs to switch between desktops in your browser.

Verifying health

bash
curl -sf http://localhost:6080/vnc.html >/dev/null && echo viewer-ok
curl -sf http://localhost:8095/api/health          # {"ok":true} only when X answers
docker compose exec desktop pgrep -f xfce4-session   # desktop process alive

The image healthcheck requires both the viewer page and the daemon health endpoint, so a dead desktop fails docker ps instead of passing with a static page.

Tips

  • Chromium is the memory hog — raise DESKTOP_MEMORY_LIMIT if you see OOM kills.
  • Watch first boot with docker compose logs -f; you should see the chain Xvfb → XFCE → x11vnc → websockify → daemon come up in order.
  • For manual GUI poking via docker exec, remember DISPLAY=:99.