Run Factorial on your own machine with Docker, and change how it runs. Quick setup installs and starts it with two commands, and you need no source code.
The image public.ecr.aws/runfactorial/factorial:latest runs as two containers:
factorial: the dashboard, API, worker, terminal and assistant.factorial-db: the Postgres database.
Before you start
You need:
- Docker with Compose, running. Docker Desktop includes both. The image is built for Intel and AMD processors only. On an Apple silicon Mac it runs under emulation, so it starts more slowly.
- GitHub access for each repository you connect. Use either a GitHub App with its private key, or a personal access token. You add it when you connect the repository. Set up the GitHub App shows how to make the App.
factorial.env
The script writes five settings into ~/factorial/factorial.env. GitHub credentials are not here: each project keeps its own in the database, encrypted.
| Setting | What it does |
|---|---|
FACTORIAL_API_TOKEN | Scripts and the assistant send it to the API, and it signs dashboard sessions. Nobody signs in with it |
FACTORIAL_MASTER_KEY | Encrypts each stored secret. A new key cannot read the old secrets |
FACTORIAL_TERMINAL__ENABLED=true | Lets you watch and type into a run from the dashboard |
FACTORIAL_RUNTIME__ALLOWED_EGRESS | The default approved hosts that every cloud sandbox run may reach. Add a host to approve it for every project. A new install starts with the npm, Yarn and PyPI registries. Each project shows them under Egress hosts, with no remove button. To allow no host, set it to [] |
FACTORIAL_DATABASE_URL | The user factorial-db-user, its password, and the database factorial-db. The database was made with this password, so do not change it |
Keep a copy of the file in a safe place. Without it, the secrets and the database do not open.
To change or add a setting, edit factorial.env, then run docker compose up -d --force-recreate in ~/factorial. The optional settings, with their defaults:
# The https origin people open the dashboard at, with no path. Unset: localhost.
# FACTORIAL_AUTH__EXTERNAL_URL=
# When set, the first sign-up must give this value to own the install.
# FACTORIAL_AUTH__BOOTSTRAP_TOKEN=
# The address or network of your proxy. Unset: 127.0.0.1 only. Never *.
# FORWARDED_ALLOW_IPS=
# Where the browser reaches the terminal service, such as https://terminal.example.com.
# FACTORIAL_TERMINAL__PUBLIC_URL=
# Seconds an idle session waits at its prompt before it parks for a person.
# FACTORIAL_TERMINAL__IDLE_PARK_AFTER=600
# Seconds a session lives before it parks for a person.
# FACTORIAL_TERMINAL__SESSION_CEILING=14400
# The runtimes people can create. The first line is the default. The second adds
# subscription logins and Codex on AWS Bedrock.
# FACTORIAL_RUNTIME__OFFERED=claude_api@local_cli,claude_api@e2b,codex_api@local_cli,codex_api@e2b
# FACTORIAL_RUNTIME__OFFERED=claude_api@local_cli,claude_api@e2b,claude_subscription@local_cli,claude_subscription@e2b,codex_api@local_cli,codex_api@e2b,codex_subscription@local_cli,codex_subscription@e2b,codex_bedrock@local_cli
# The sign-ins people can choose for the assistant. The first line is the default. The second
# adds the subscriptions and Codex on AWS Bedrock.
# FACTORIAL_ASSISTANT__OFFERED=claude_sdk:api_key,codex_cli:api_key
# FACTORIAL_ASSISTANT__OFFERED=claude_sdk:api_key,claude_sdk:subscription,codex_cli:api_key,codex_cli:subscription,codex_cli:bedrock
# The hosts every cloud sandbox run may reach. A new install writes this line. A file without
# it allows no host, so add it to an older file to let agents install packages.
# FACTORIAL_RUNTIME__ALLOWED_EGRESS=["registry.npmjs.org","registry.yarnpkg.com","repo.yarnpkg.com","pypi.org","files.pythonhosted.org"]
# The name on each managed cloud sandbox. Filled in on first start and kept on the volume.
# Set your own to keep it across reinstalls. No other install may use it.
# FACTORIAL_RUNTIME__E2B__DEPLOYMENT=
# Lets anyone sign up and make an organization. Then only managed cloud sandbox runtimes
# are offered, unless FACTORIAL_RUNTIME__OFFERED lists others.
# FACTORIAL_MULTI_ORG__ENABLED=false
# How long a finished run's workspace is kept.
# FACTORIAL_WORKSPACE__RETENTION=7d
Database
The database answers at 127.0.0.1:5432, on this machine only. The password is the text between factorial-db-user: and @ in FACTORIAL_DATABASE_URL:
psql "postgresql://factorial-db-user:PASSWORD@127.0.0.1:5432/factorial-db"
In SQL, put both names in double quotes, such as "factorial-db", because they hold a hyphen.
First runtime
A runtime runs the agents. In the dashboard, open Runtimes and push Create runtime. By default it offers Claude Code and Codex with an API key, in one of two places:
| Place | Where agents run | What it needs |
|---|---|---|
| On the host | In the factorial container | The API key. Codex also needs user namespaces, which seccomp.json allows for each process in the container. compose.yaml applies it |
| Managed sandbox | Each in an E2B sandbox of its own | Your E2B team's key, and a template that team built |
The sample processes name the slug claude-api (on the host) or claude-api-on-e2b (managed sandbox). The form suggests these slugs, and a slug cannot change later.
Sandbox template
A template is private to the E2B team that built it. Read your keys without writing them to your shell history:
macOS
printf 'E2B key: '; read -rs E2B_API_KEY; echo; printf 'Anthropic key: '; read -rs ANTHROPIC_API_KEY; echo; export E2B_API_KEY ANTHROPIC_API_KEY
Linux
printf 'E2B key: '; read -rs E2B_API_KEY; echo; printf 'Anthropic key: '; read -rs ANTHROPIC_API_KEY; echo; export E2B_API_KEY ANTHROPIC_API_KEY
Windows (PowerShell)
$env:E2B_API_KEY = [Net.NetworkCredential]::new('', (Read-Host 'E2B key' -AsSecureString)).Password; $env:ANTHROPIC_API_KEY = [Net.NetworkCredential]::new('', (Read-Host 'Anthropic key' -AsSecureString)).Password
docker exec -it -e E2B_API_KEY -e ANTHROPIC_API_KEY factorial python -m orchestrator.e2b_template claude
For Codex, read OPENAI_API_KEY in place of ANTHROPIC_API_KEY, then run:
docker exec -it -e E2B_API_KEY -e OPENAI_API_KEY factorial python -m orchestrator.e2b_template codex
The build installs the newest agent CLI, then tests the sandbox firewall and a short agent session, billed to your E2B team and API key. It prints a pin only when both tests pass. Then store the E2B key on the runtime and choose the build.
Connect a repository
Follow Connect a repository.
Let other people in
The ports listen on 127.0.0.1. Keep it so until your owner account exists, or first add a bootstrap token. This command, in ~/factorial, adds one to factorial.env and prints it:
docker run --rm --platform linux/amd64 -v "${PWD}:/out" --entrypoint python public.ecr.aws/runfactorial/factorial:latest -c "import secrets; t = secrets.token_urlsafe(32); open('/out/factorial.env', 'a').write(chr(10) + 'FACTORIAL_AUTH__BOOTSTRAP_TOKEN=' + t + chr(10)); print(t)"
After docker compose up -d --force-recreate, only a sign-up that gives the token becomes the owner.
To open Factorial to other people:
- Put a proxy with TLS in front of port 8000.
- Set
FACTORIAL_AUTH__EXTERNAL_URLto the origin people open. Invite links name it. Requests that change a setting or give a credential (assistant settings, MCP tokens, the terminal, adopting a config branch push) work only from that origin, from each origin inFACTORIAL_CORS_ORIGINS, and fromlocalhost:8000or127.0.0.1:8000. - Set
FORWARDED_ALLOW_IPSto the proxy's address or network, such as172.16.0.0/12for a proxy on a Docker network. Without it, the API sees one address for all clients, so one client can use up the password tries of every account, the owner's too. Never write*, which lets each client choose its own address. - Route the terminal service, as below.
- Invite each person from the Members page (Accounts and access).
Terminal service
| When | The dashboard reaches the terminal at |
|---|---|
FACTORIAL_TERMINAL__PUBLIC_URL is set | That origin |
FACTORIAL_AUTH__EXTERNAL_URL is empty or a loopback host | Port 8001 on that host, which compose.yaml publishes |
FACTORIAL_AUTH__EXTERNAL_URL names another host | Its own origin. Your proxy must send /factorial/terminal/ to port 8001, WebSocket connections too |
Check it with curl -fsS http://localhost:8001/factorial/terminal/healthz, or curl.exe in PowerShell.
Upgrade
The dashboard's Help menu shows the running version, as does docker inspect factorial --format "{{.Config.Image}}". The newest is 0.1.10. compose.yaml pins a tag that never changes, so a restart keeps your version.
To upgrade, read the release notes, then run Step 1 of Quick setup again in a terminal. When a newer version exists, the script asks first. On y, it:
- Pulls the new version. A failed pull changes nothing.
- Runs
docker compose down, which removes both containers and keeps the volume. - Backs up the whole volume to
~/factorial/backups/factorial-OLD-TIME.tgz, whereOLDis the installed version andTIMEis in UTC. - Pins the new version in
compose.yaml. Run Step 2 of Quick setup to start it. It migrates the database when it starts.
With no terminal, such as in a script, it keeps the installed version and prints the upgrade line. To upgrade with no question, use a line from the version list. Each upgrade writes compose.yaml again, so your edits to it do not last.
Data and shutdown
The factorial-public volume, at /data in both containers, holds all of the state. New containers keep it, given the same factorial.env.
| Folder | What it holds |
|---|---|
/data/postgres | The database: projects, tickets, the event log, accounts and the encrypted secrets |
/data/runs | The agent run folders, and the state of each managed sandbox run |
/data/assistant | The assistant's work folders |
/data/e2b-deployment | The name on this install's managed sandboxes |
Run these in ~/factorial:
docker compose stop # stop both containers; the data stays
docker compose up -d --wait # start them again
docker compose down # remove the containers, not the data
docker volume rm factorial-public # after a down: delete all the data
Use docker compose stop, not docker rm -f, so the terminal service can close its terminals. A stop ends each agent session, and its step starts again at the next start. After docker volume rm, Step 2 of Quick setup makes a new, empty database with the same factorial.env.
Troubleshooting
A container writes the reason it stopped to its log: docker logs factorial or docker logs factorial-db. After you correct factorial.env, run docker compose up -d --force-recreate in ~/factorial.
| Problem or message | What to do |
|---|---|
A Factorial data volume already exists | Put the factorial.env the volume was made with in ~/factorial, or run docker volume rm factorial-public to start over |
The backup failed | Run docker compose up -d in ~/factorial, fix the cause, such as a full disk, then run Step 1 of Quick setup again |
different FACTORIAL_MASTER_KEY, FACTORIAL_MASTER_KEY is empty or password authentication failed for user "factorial-db-user" | Put back the factorial.env the volume was made with, or run docker volume rm factorial-public to start over |
container name "/factorial" is already in use | Run docker stop factorial factorial-db, then docker rm factorial factorial-db, then Step 2 of Quick setup again. The data stays in its volume |
port is already allocated or address already in use | Stop the program that uses port 8000, 8001 or 5432, such as a Postgres server, then run Step 2 of Quick setup again |
no configuration file provided | Run docker compose in ~/factorial |
FACTORIAL_API_TOKEN is empty, is shorter than 32 characters or is a published sample value | Set it to a new random value of 32 characters or more |
settings do not load | A value in factorial.env has the wrong form. The message names it |
the environment also holds or is in the services' environment | Remove each variable it names from the environment entries of compose.yaml, and put it in factorial.env |
FACTORIAL_AUTH__EXTERNAL_URL is empty in the log, or Change the assistant settings from the dashboard. | Set FACTORIAL_AUTH__EXTERNAL_URL to the origin people open |
A request from in the log | Add the proxy's address to FORWARDED_ALLOW_IPS |
Pulling the image fails with pull access denied or another authorization error from public.ecr.aws | Docker cached an expired ECR Public login. The image needs no login: run docker logout public.ecr.aws and pull again. For the higher limits of a signed-in pull, run aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws |
| A repository that another Factorial install manages | Its factorial branch was not written by this install, so sync waits until a person reviews it and pushes Adopt and sync. Create runtimes with the slugs its processes name |
A setting passed with -e, --env-file or an environment entry in compose.yaml | Put it in factorial.env instead. Every agent run inherits the worker's environment, and the master key must not reach an agent |
Docker needs sudo on Linux | Add yourself to the docker group. The script never uses sudo |
| Codex agents on the host do not start on Ubuntu 23.10 or later | AppArmor blocks the user namespaces they need. Use Claude Code or the managed cloud sandbox, which are not affected |