2026-04-09 14:21:30 +07:00
# Docker
2026-05-13 18:22:31 +07:00
Run 9Router in a container. Published image: [`decolua/9router` ](https://hub.docker.com/r/decolua/9router ) — multi-platform `linux/amd64` + `linux/arm64` .
2026-04-09 14:21:30 +07:00
2026-05-13 18:22:31 +07:00
---
2026-04-09 14:21:30 +07:00
2026-05-13 18:22:31 +07:00
# 👤 For Users
2026-04-09 14:21:30 +07:00
2026-05-13 18:22:31 +07:00
## Quick start
2026-04-09 14:21:30 +07:00
```bash
docker run -d \
-p 20128:20128 \
-v " $HOME /.9router:/app/data" \
2026-04-10 10:14:34 +07:00
-e DATA_DIR = /app/data \
2026-04-09 14:21:30 +07:00
--name 9router \
2026-05-13 18:22:31 +07:00
decolua/9router:latest
2026-04-09 14:21:30 +07:00
```
2026-05-13 18:22:31 +07:00
App listens on port `20128` . Open: http://localhost:20128
## Manage container
2026-04-09 14:21:30 +07:00
```bash
2026-05-13 18:22:31 +07:00
docker logs -f 9router # view logs
docker stop 9router # stop
docker start 9router # start again
docker rm -f 9router # remove
2026-04-09 14:21:30 +07:00
```
2026-05-13 18:22:31 +07:00
## Data persistence
2026-04-09 14:21:30 +07:00
```bash
2026-05-13 18:22:31 +07:00
-v " $HOME /.9router:/app/data" \
-e DATA_DIR = /app/data
```
Without `DATA_DIR` , the app falls back to `~/.9router/` (macOS/Linux) or `%APPDATA%\9router\` (Windows). In the container, `DATA_DIR=/app/data` makes the bind mount work.
Data layout under `$DATA_DIR/` :
```text
$DATA_DIR/
├── db/
│ ├── data.sqlite # main SQLite database
│ └── backups/ # auto backups
└── ... # certs, logs, runtime configs
```
Host path: `$HOME/.9router/db/data.sqlite`
Container path: `/app/data/db/data.sqlite`
## Optional env vars
```bash
docker run -d \
2026-04-09 14:21:30 +07:00
-p 20128:20128 \
-v " $HOME /.9router:/app/data" \
2026-04-10 10:14:34 +07:00
-e DATA_DIR = /app/data \
2026-04-09 14:21:30 +07:00
-e PORT = 20128 \
-e HOSTNAME = 0.0.0.0 \
-e DEBUG = true \
--name 9router \
2026-05-13 18:22:31 +07:00
decolua/9router:latest
```
## Update to latest
```bash
docker pull decolua/9router:latest
docker rm -f 9router
# re-run the quick start command
```
---
# 🛠 For Developers
## Build image locally
```bash
# from repo root
npm run docker:build
```
Or directly:
```bash
cd app && docker build -t 9router .
```
Run local build:
```bash
docker run --rm -p 20128:20128 \
-v " $HOME /.9router:/app/data" \
-e DATA_DIR = /app/data \
2026-04-09 14:21:30 +07:00
9router
```
2026-05-13 18:22:31 +07:00
## Publish to Docker Hub (multi-platform)
Triggered automatically by `npm run cli:publish` . Manual:
2026-04-09 14:21:30 +07:00
```bash
2026-05-13 18:22:31 +07:00
# 1. Login once
docker login
# 2. Build amd64 + arm64 + push (tag from app/cli/package.json version)
npm run docker:publish
2026-04-09 14:21:30 +07:00
```
2026-05-13 18:22:31 +07:00
Tags pushed:
- `decolua/9router:v{version}`
- `decolua/9router:latest`