How do I run browser profiles in Docker?
Published December 5, 2026 · Updated December 5, 2026 · Mirage Browser
Run the browser in a container with a persistent data volume, enough shared memory, a virtual display if you want windows, and secrets passed as files rather than baked into the image. Bind the control port to localhost or put TLS in front of it. Keep the volume and its key backed up separately, because the profiles live there.
Why do browsers crash in containers?
The most common reason is shared memory. Docker gives a container 64 MB of /dev/shm by default, and a browser uses it for rendering. Pages with heavy graphics then crash or hang. Set shm_size to a gigabyte or two. The second reason is a missing display: a browser started with a window needs one, so the container runs a virtual display, or the browser runs headless.
Where do profiles live?
In a volume, never in the container’s own layer. A container is replaced on every update; a volume stays. Back the volume up like any database: it holds cookies and storage that open accounts.
How should secrets get into the container?
As files mounted at run time, not as environment variables in the image or the Compose file. Docker Compose secrets mount a file under /run/secrets/, readable inside the container and absent from the image:
services:
mirage:
image: mirage-headless
shm_size: 2gb
ports:
- "127.0.0.1:35000:35000"
volumes:
- mirage-data:/data
environment:
MIRAGE_DEVICE_KEY_FILE: /run/secrets/mirage_device_key
secrets:
- mirage_device_key
volumes:
mirage-data:
secrets:
mirage_device_key:
file: ./device.keyIn the Mirage headless runner, which comes with the public beta, the device key seals proxy passwords and recordings in the volume. Lose the key and that data cannot be opened, so keep a copy off the server.
Who can reach the control port?
Whoever reaches it controls every profile. Bind it to 127.0.0.1, as above, and connect from the same machine. For access from elsewhere put a TLS reverse proxy such as Caddy or nginx in front, and limit the port with a firewall. Plain HTTP across a network sends the API key in clear text.
Headless or a window on a virtual display?
Headless mode is lighter, but some sites can tell it apart from a normal browser. A window on a virtual display looks like a desktop browser and costs more memory. Start with windows and switch to headless only where you have checked it works.
How do I check it works?
docker compose up -dand read the logs.- Create and start one profile from the command line.
- Connect a script and open a page that shows the IP and browser values, such as our browser check.
export MIRAGE_LOCAL_API_URL=http://127.0.0.1:35000
mirage profiles create "Worker 1"
mirage profiles start "Worker 1"Full setup: headless and Docker and command line.