Self-host

Self-host Dex

Dex runs as one Docker container on a machine you own. You connect to it from the Dex phone app.

Dex is licensed for your own personal use: you may not copy, modify, resell or share it. The plain-English summary is defaults/docs/license.md, and the binding terms are in LICENSE.

Requirements:

  • A machine running Docker
  • A phone
  • Node, git, tmux and the agent tools for every AI provider Dex supports are inside the image

The Dex phone app

Download for free in the app stores.

Download on the App StoreGet it on Google Play
1

Create the projects directory

Use the block for your machine.

macOS
macOS
mkdir -p $HOME/dex-projects
Linux
Linux
mkdir -p $HOME/dex-projects
sudo chown -R 1000:1000 $HOME/dex-projects
Windows
Windows, in PowerShell
New-Item -ItemType Directory -Force -Path "$HOME\dex-projects"
2

Start the server

Accept the license

Dex doesn't start until you accept its license. Read it first:

docker run --rm --entrypoint cat ghcr.io/killerbee05/dex:latest /app/LICENSE

Command 2 below accepts it with -e DEX_ACCEPT_LICENSE=yes. Without that, Dex never gets going: Docker keeps trying to start it, and docker logs dex says why each time.

Run Dex

Replace APP_PORT and MOCK_PORT before running this. Suggested port ranges 1024 to 32767.

Make sure the APP_PORT and MOCK_PORT are different values.

  • APP_PORT — the port the app connects to.
  • MOCK_PORT — the port that serves design playground links. It appears three times in the command; use the same number in all three.
Command 1 creates the network Dex runs on
docker network create -o com.docker.network.bridge.name=dex-net dex-net
Command 2
docker run -d --name dex --network dex-net --init --restart unless-stopped --security-opt no-new-privileges --cap-drop ALL --pids-limit 512 -p APP_PORT:7682 -p MOCK_PORT:MOCK_PORT -e DEX_MOCK_PORT=MOCK_PORT -e DEX_ACCEPT_LICENSE=yes -v dex-claude:/home/dex/.claude -v dex-registry:/var/lib/dex -v $HOME/dex-projects:/projects ghcr.io/killerbee05/dex:latest

Running a second Dex on the same machine? It needs its own --name, ports, volume names and network, in every command. Its network name goes in both places in Command 1 and after --network in Command 2. It starts with dex- and is at most 15 characters, for example dex-net2.

If your phone can't connect, a firewall may be blocking APP_PORT. Check that your computer's firewall allows incoming connections on that port.

Windows

Windows only, so your phone can reach it. In Terminal as Administrator:

New-NetFirewallRule -DisplayName "Dex" -Direction Inbound -Protocol TCP -LocalPort APP_PORT -Action Allow

On a Mac with OrbStack: keep your Dex containers apart (optional)

This is for a Mac that runs other people's Dex containers side by side. If yours is the only Dex on this Mac, skip this section.

macOS

Run this once. It starts a small firewall container that stops one Dex container from reaching another on this Mac, by its address or through this Mac's ports. Your phone and the internet still reach every Dex, and Dex can still reach your Mac, for example over SSH or a service you run on it. It restarts with OrbStack and keeps running through Dex updates.

docker run -d --name dex-fence --restart always --net=host --cap-drop ALL --cap-add NET_ADMIN ghcr.io/killerbee05/dex-fence:latest

Use it with OrbStack only. It covers every Dex container on a network whose name starts with dex-, like the one Command 1 creates. Each Dex needs a network of its own: two on the same network can still reach each other.

Started a Dex before its install used Command 1? It is not covered until you recreate it: follow Update by hand under Updating the Dex server below for each one.

Dex can tell you when it isn't isolated. Turn the check on by adding -e DEX_FENCE_CHECK=1 to each Dex container's docker run command, recreating it as in Update by hand under Updating the Dex server below. The one-command update keeps it; if you update by hand, add it to Command 4 every time, or the check turns off again. Each time it starts, and each time you open the app, that Dex checks for the fence. If the fence isn't running, or that Dex isn't on its own dex- network, your Inbox gets one card from Dex: "Dex isn't isolated on this Mac". The card goes away by itself once the fence is up and you open the app again. A Dex started without -e DEX_FENCE_CHECK=1 doesn't check, and shows no card.

What it costs:

  • A Dex container cannot reach another Dex's published port number on this Mac or at a private address, such as another computer on your home network or on Tailscale. Public internet addresses are not affected.
  • A Dex container cannot connect to port 47123 anywhere. The fence turns that port away on purpose, and that is how Dex knows the fence is there.
  • A connection that was already open when the fence started, or when you removed a pair, stays open until it closes.
  • While the fence is stopped, ports opened after it stopped are not covered.

Need port 47123 for something else? Pick another port, and pass it to the fence and to every Dex container as -e DEX_FENCE_CANARY_PORT=PORT. Use the same number in all of them, or a Dex with the check on warns that it isn't isolated when it is.

macOS

To let two of your Dex containers talk to each other, recreate the fence with their two network names:

docker rm -f dex-fence
docker run -d --name dex-fence --restart always --net=host --cap-drop ALL --cap-add NET_ADMIN -e ALLOW="dex-net,dex-net2" ghcr.io/killerbee05/dex-fence:latest

To take the fence off, remove it, then clear the rules it left behind:

docker rm -f dex-fence
docker run --rm --net=host --cap-drop ALL --cap-add NET_ADMIN ghcr.io/killerbee05/dex-fence:latest remove
3

Get your pairing code

Do not share your pairing code!

Command
docker exec dex node /app/scripts/pair-code.js

It prints a short code like K7QM-2F9X. It works once and expires in 10 minutes.

4

Make the server reachable from your phone

Same WiFi works by default. The other is needed to connect when you are away from home.

  • Same WiFi (default)

    Works only while both devices are on that network.

  • Cloudflare zero trust tunnel

    works for iOS or Android

5

Connect the app

Enter:

  • Server Address — your ip address
  • Server Port — the APP_PORT you chose in step 2.
  • Pairing code — from step 3.
Later

Updating the Dex server

Run this on the computer Dex runs on. It updates Dex and keeps your ports, data, network and pairing. If the new Dex doesn't start, it puts the old one back.

docker run --rm --pull always --name dex-update --user 0 --entrypoint node -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/killerbee05/dex:latest /app/scripts/dex-update.js dex

The last line it prints says how it went: updated to …, already up to date, or why it stopped. rolled back: means the new Dex didn't start and your old one is back. --user 0 lets it reach Docker, which on Linux only root and the docker group can use.

A second Dex on the same machine uses its own container name: dex2-update wherever dex-update appears, and dex2 in place of the dex after dex-update.js.

If your Dex was installed before Dex asked you to accept its license, the update stops with Nothing was changed and gives you the command that shows the license. Once you have read it, run the update again with --accept-license at the end:

docker run --rm --pull always --name dex-update --user 0 --entrypoint node -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/killerbee05/dex:latest /app/scripts/dex-update.js dex --accept-license

You only need it once. The updated Dex keeps your acceptance from then on.

Ask your Dex to update itself

If your Dex can reach this computer over SSH, ask it to update itself. It runs the same command with -d, so the update carries on after Dex stops, and without --rm, so its output is kept for you to read:

docker run -d --pull always --name dex-update --user 0 --entrypoint node -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/killerbee05/dex:latest /app/scripts/dex-update.js dex

Dex disconnects briefly, and the app reconnects on its own. Afterwards, docker logs dex-update shows how it went, and docker rm dex-update clears it for the next update. If it says Nothing was changed because of the license, read the license, then ask again with --accept-license at the end of the command, as above.

Never have Dex run the four commands below. The second one stops Dex partway through, the fourth never runs, and you are left with no Dex.

Update by hand

From this computer's own terminal. A second Dex on the same machine uses its own names in these commands too.

Command 1
docker pull ghcr.io/killerbee05/dex:latest
Command 2
docker rm -f dex

Command 3 creates the network Dex runs on. A second Dex uses its own network name here, the one from step 2. If it says the network already exists, go on to Command 4.

docker network create -o com.docker.network.bridge.name=dex-net dex-net
Command 4
docker run -d --name dex --network dex-net --init --restart unless-stopped --security-opt no-new-privileges --cap-drop ALL --pids-limit 512 -p APP_PORT:7682 -p MOCK_PORT:MOCK_PORT -e DEX_MOCK_PORT=MOCK_PORT -e DEX_ACCEPT_LICENSE=yes -v dex-claude:/home/dex/.claude -v dex-registry:/var/lib/dex -v $HOME/dex-projects:/projects ghcr.io/killerbee05/dex:latest