具有主观观点的数据库部署套件 — 为 PostgreSQL 本地运行的 RDS
Run PostgreSQL on your own Linux box with the ergonomics of a managed service.
ODDK is a single Go binary that manages PostgreSQL the way a cloud provider's managed database does — create an instance, get a connection string, take scheduled snapshots, ship them offsite to S3, watch health, restore on demand, upgrade major versions — except it all runs locally against Docker, on hardware you control. Think "a small, self-hosted RDS for Postgres."
oddk create --name app --version 17 --port 5432 --cpu 4 --ram 8 # pulls the image if needed
oddk instance get-postgres-password app --conn
# postgresql://postgres:••••••••@10.88.0.1:5432/postgres127.0.0.1 and
Postgres binds to a host-local Docker bridge. Reach them over an SSH tunnel,
not by exposing ports.pgvector/postgis);
it doesn't replace your client library or PgBouncer.If you've ever wanted RDS-style convenience — "give me a database, back it up,
tell me when it's unhealthy, let me restore it" — without the cloud bill, the
network exposure, or hand-rolling docker run + pg_dump + cron + a monitoring
script, ODDK is that, as one tool with one mental model.
| You want… | ODDK gives you… |
|---|---|
| A new database, fast | oddk create → ready-to-use Postgres with a connection string |
| Confidence it's backed up | snapshot make, one scheduled snapshot covering everything, S3 offsite with retention |
| To not lose data | snapshot restore-instance (one instance) or snapshot apply (a whole host) |
| To know when it breaks | Health checks + degraded/restored notifications |
| To tune Postgres safely | AWS-style parameter groups with expression evaluation |
| To move to a new major | instance major-upgrade via dump/restore |
| Secrets handled properly | AES-256-GCM-encrypted passwords, tokenized API auth |
ODDK is a Docker control plane. Run it on the host, directly on the machine that runs Docker — never inside a container.
The whole point of ODDK is to manage and monitor Docker: it creates and
destroys PostgreSQL containers, attaches them to a host bridge network, reads
host disk/CPU/memory for health checks, and writes state and snapshot/backup
archives to host paths. That is the opposite of being a containerized workload itself. Running
ODDK inside Docker inverts the relationship and breaks its assumptions —
host-level resource metrics, the 10.88.0.0/16 bridge and 10.88.0.1 gateway
binding, data/backup paths, and the systemd service lifecycle all expect a host
process. Bind-mounting the Docker socket into a container to work around this is
exactly the inversion ODDK is designed to avoid, and is not supported.
If what you actually want is to run a database inside Docker/Compose as part of a containerized stack, that is a different problem with different tools — use Docker Compose, a Kubernetes operator, or your platform's managed database instead. ODDK is for owning the host and treating Docker as the thing it drives.
On a Linux server with Docker and systemd, install (or update) the latest release:
curl -fsSL https://raw.githubusercontent.com/andrianbdn/oddk/main/install.sh | shPin a specific version:
curl -fsSL https://raw.githubusercontent.com/andrianbdn/oddk/main/install.sh | sh -s -- --version v0.1.39The installer downloads the release binary from GitHub, verifies it against the
published SHA256SUMS, and:
/usr/local/bin/oddkoddk service user (no login shell) with state under
/var/lib/oddk (data/, backups/)oddk.service)~/.config/oddk/cli.jsonThat last step means the person who runs the installer can use oddk right
away — no sudo, no becoming the oddk user.
Installing and updating use the same command. Re-run the curl installer at
any time — on an existing install it detects the service, swaps the binary in
place, restarts, and keeps the previous binary as oddk.prev for instant
rollback. There is no separate update step.
Before updating, skim CHANGELOG.md. Most releases need nothing from you, but the entries marked Action do — a credential to rotate, or a schedule to resume after a disaster-recovery restore.
The CLI authenticates to the daemon with a bearer token. To set up oddk for an
additional user, mint a token and install their config in one step:
eval "$(sudo -u oddk /usr/local/bin/oddk auth mint)"The plaintext token is shown only when created and cannot be read back later. If you lose it, mint a new one with
oddk auth mint. Useoddk auth mint --jsonto print the config instead of eval-able shell,oddk auth listto see existing tokens, andoddk auth deleteto revoke one.
After installation the daemon is running and your CLI is configured. From here:
# 1. Create an instance — 4 CPUs, 8 GB RAM, listening on port 5432.
# The PostgreSQL image is pulled automatically if it isn't already local.
oddk create --name app --version 17 --port 5432 --cpu 4 --ram 8
# 2. See what you have
oddk list
# 3. Get connection details (password is auto-generated, encrypted at rest)
oddk instance get-postgres-password app --conn # full connection string
eval "$(oddk instance get-postgres-password app --envs)" # export PG* env vars
# 4. Open a psql shell
oddk instance psql appConnecting from the host:
postgresql://postgres:[email protected]:/postgresConnecting from another Docker container (e.g. your app's docker-compose.yml):
extra_hosts:
- "host.docker.internal:host-gateway"
# then: postgresql://postgres:[email protected]:/postgresoddk is organized into subcommands. Everything below has --help
(oddk instance --help, oddk snapshot --help, …).
…Create/start/switch/reconfigure block until Postgres actually accepts connections before reporting success, so a command never returns "running" while the server is still coming up.
Deploying a new service? One command creates the database and its owner user (rolling back the user if database creation fails), and prints the generated password and a ready-to-paste connection string. The user owns the database, so migrations just work:
oddk instance create-db app --database billing --username billing # DB + owner userThe pieces are also available separately (read-only and extra users are added
with add-db-user once the database exists):
oddk instance create-db app --database analytics
oddk instance list-dbs app
oddk instance add-db-user app --username appuser --database analytics # read-write
oddk instance add-db-user app --username reader --database analytics --readonly # read-only
oddk instance add-db-user app --username appuser --database analytics --owner # owner (runs migrations)
oddk instance reset-db-user-password app --username appuser
oddk instance delete-db-user app --username appuseradd-db-user creates the role, grants access, and applies any requested ownership
changes in one transaction. A failed grant or ownership transfer rolls all of them
back. Ownership transfer includes public-schema functions and stored procedures.
delete-db-user first reassigns everything the user owns to postgres, then
revokes its grants and drops the role. If that reassignment fails the command
aborts and leaves the user in place — it will not proceed to a step that would
drop the objects instead of the grants. On a very large database the reassign
can exhaust the shared lock table (out of shared memory ... increase max_locks_per_transaction); raise max_locks_per_transaction with a parameter
group and retry.
Concurrent application DDL is also guarded: if a new object would be deleted during privilege cleanup, the command aborts and rolls back that database's cleanup, preserving the object and the user. Stop the application's DDL and retry. Cleanup already completed in other databases is not rolled back.
oddk instance get-postgres-password app # structured details
oddk instance get-postgres-password app --plain # just the password
oddk instance get-postgres-password app --conn # connection string
NEW_PGPASSWORD=secret oddk instance set-postgres-password appA snapshot captures everything: every instance's databases and roles, plus ODDK's own configuration, in one archive. It is what a host migration or a real disaster recovery restores from. A per-instance backup cannot do that — it holds one instance's data and none of the configuration needed to rebuild it.
…One instance failing does not cost the others their archive. If an instance
cannot be captured — its server is unreachable, its stored password no longer
authenticates, PostgreSQL is out of WAL senders, its container has vanished — that
instance is recorded in the snapshot as configuration-only and everything else is
captured normally. The
archive is kept, uploaded and catalogued, because it is still the newest restore
point for every other instance. But the run reports failure: snapshot make
exits non-zero and names the insta
暂无开放 Issues,或尚未同步最近议题。