Headless runner and Docker
The headless runner is Mirage without a window: the same engine that starts profiles in the desktop app, with the same Local API, on a Linux server. A script creates profiles, starts them and connects with Playwright exactly as it does on your computer.
The image is published together with the public beta. Until then it is available on request from Mirage support.
What the runner does and does not do yet
- It runs profiles on the Firefox-based core that ships in the image.
- Without an account it keeps local profiles in its own data volume, within the Free limits on that machine (10 profiles, 5 browsers at a time through the API).
- Signed in to a Mirage account, it syncs your cloud profiles and works within your plan. See “Sign in to your account” below.
- Chrome profiles need a Chromium core, which is not in the image yet.
- The image is for
linux/amd64.
Start it
-
Make a device key. It seals the proxy passwords and recordings in the data volume.
Terminal window openssl rand -base64 32 > device.keychmod 600 device.keysudo chown 10001 device.keyThe runner works in the container as user 10001, so the file must belong to that user.
Keep a copy somewhere other than the server. Without this file the sealed data in the volume cannot be opened.
-
Save this as
compose.ymlnext todevice.key:services:mirage:image: mirage-headlessrestart: unless-stoppedshm_size: 2gbstop_grace_period: 30sports:- "127.0.0.1:35000:35000"volumes:- mirage-data:/dataenvironment:MIRAGE_DEVICE_KEY_FILE: /run/secrets/mirage_device_keysecrets:- mirage_device_keyvolumes:mirage-data:secrets:mirage_device_key:file: ./device.key -
Start it and take the API key the runner made on its first start:
Terminal window docker compose up -ddocker compose exec mirage mirage-headless key
The API now answers on http://127.0.0.1:35000 of the server. docker compose down closes the browsers and saves their sessions first; give it the 30 seconds from the file above.
Run one runner per data volume.
Use it
From the same machine, point the SDK or the command line at the runner:
export MIRAGE_LOCAL_API_URL=http://127.0.0.1:35000export MIRAGE_API_KEY=mrg_…mirage profiles create "Shop 1"mirage profiles start "Shop 1" # prints the Playwright endpointThe mirage command is also inside the container, already signed in: docker compose exec mirage mirage profiles list.
Everything in the SDK, the command line and the Local API reference works the same way.
With a window or without
A profile starts with a window unless you ask otherwise. The container has a virtual display, so the window exists but nobody sees it. To a website this looks like a browser on a desktop. Starting with headless: true (mirage profiles start --headless) skips the window; some sites can tell.
Reach it from another machine
An API key sent over plain HTTP can be read by anyone on the way. So the runner is published on 127.0.0.1 above, and other machines need TLS in front of it. Two ways:
A reverse proxy with TLS
A proxy (Caddy, nginx, Traefik) on the same server passes requests on to 127.0.0.1:35000, WebSocket upgrades included. Tell the runner the address clients use, so that it accepts it and puts it into Playwright endpoints:
environment: MIRAGE_PUBLIC_URL: https://runner.example.comTLS in the runner itself
Mount your certificate files into the container:
ports: - "35000:35000" environment: MIRAGE_TLS_CERT_FILE: /certs/fullchain.pem MIRAGE_TLS_KEY_FILE: /certs/privkey.pem MIRAGE_PUBLIC_URL: https://runner.example.com:35000On the other machine, use the same address as in MIRAGE_PUBLIC_URL:
export MIRAGE_LOCAL_API_URL=https://runner.example.com # behind a reverse proxyexport MIRAGE_LOCAL_API_URL=https://runner.example.com:35000 # TLS in the runner itselfWhoever holds the API key controls every profile on the runner, including its cookies and saved logins. Limit who can reach the port with a firewall as well.
Selenium’s debuggerAddress is not available from another machine: it is a port inside the container.
Sign in to your account
Stop the runner, then run the sign-in in the same data volume. It needs a terminal, so use -it:
docker compose stopdocker compose run --rm -it mirage login --email you@example.com--google and --telegram work the same way and print an address to open instead of sending a letter.
- Open the link from the letter in any browser, on any machine.
- The browser ends on an address that starts with
http://127.0.0.1. On the runner’s own machine that finishes the sign-in. On another machine the page does not open: copy the address from the address bar and paste it into the terminal. - The runner then needs the keys of your account. Open Mirage on a device that is already signed in, go to the account settings and approve the new device with the 6 digits the terminal shows. If you have no such device at hand, run the command with
--recoveryand type your 24-word recovery key instead. - Start the runner again:
docker compose up -d. Its log says which account it works under.
On a new account that never had cloud sync, the runner creates the vault itself. It shows 24 words once and asks for three of them back. Write them down and keep them away from the server: without them and without a signed-in device nobody can open your cloud data.
The session and the keys are stored in the data volume, sealed with the device key. mirage-headless logout ends the session; local profiles stay.
The runner receives cloud profiles by sync. To make a profile a cloud one, use the desktop app.
An image without a server set needs MIRAGE_API_URL, and the public keys the server signs with in MIRAGE_ENTITLEMENT_KEYS and MIRAGE_REMOTE_CONFIG_KEYS.
Only one runner can use a data volume at a time. A second one refuses to start.
Settings
| Variable | Meaning | In the image |
|---|---|---|
MIRAGE_USER_DATA_DIR |
Data directory: profiles, keys, settings | /data |
MIRAGE_DEVICE_KEY_FILE |
Device key file, 32 random bytes in base64. Created on the first start if missing | /data/device.key |
MIRAGE_LISTEN_HOST, MIRAGE_LISTEN_PORT |
Where the runner listens for clients | 0.0.0.0, 35000 |
MIRAGE_PUBLIC_URL |
The address clients use, when it differs: a reverse proxy or a remapped port | — |
MIRAGE_TLS_CERT_FILE, MIRAGE_TLS_KEY_FILE |
Serve TLS with these PEM files | — |
MIRAGE_ALLOW_PLAINTEXT |
1 allows plain HTTP on a non-loopback address |
1, because the published port decides who reaches it |
MIRAGE_CORE_PATH |
Browser core for Firefox profiles | the core in the image |
MIRAGE_API_URL |
The Mirage server to sign in to. https:// only |
set when the image is built |
MIRAGE_REMOTE_COMMANDS |
1: start and stop profiles on commands that other devices of the account sign; 0: do not take them, they expire on the server |
off |
MIRAGE_XVFB |
0 turns the virtual display off; profiles then start only with headless: true |
on |
If you publish the port under another number, for example -p 127.0.0.1:8080:35000, set MIRAGE_PUBLIC_URL=http://127.0.0.1:8080: the runner refuses requests that name an address it does not know.
Without Docker
On a Linux server with Node 24, a display (or xvfb-run) and a core on disk, the same runner starts as mirage-headless with the variables above. Without MIRAGE_LISTEN_HOST it listens only on the loopback of that machine, on a random port the SDK and the command line find on their own through MIRAGE_USER_DATA_DIR. Stop it with SIGTERM (systemctl stop, kill): Ctrl+C in a terminal also kills the browsers before they save their sessions.