PostgreSQL — the world's most advanced open-source relational database, deployed as a host-networked Nomad service with a persistent Docker volume.
Save as values.hcl, edit, then run:
# The name of the Nomad job.
job_name = "postgres"
# The Nomad namespace to deploy into.
namespace = "default"
# The datacenters to deploy to.
datacenters = ["*"]
# The PostgreSQL container image.
image = "postgres:16-alpine"
# Host port Postgres listens on (host networking, so it's reachable at <node-ip>:<port>). Pick a free port on the target node.
port = 5432
# Number of instances (keep at 1 — local-disk storage, no built-in replication).
count = 1
# Initial database created on first boot.
db_name = "app"
# Superuser role created on first boot.
db_user = "app"
# Password for db_user. CHANGE THIS — it is baked into the job env. Consider a Nomad variable / Vault instead of a default.
db_password = "postgres"
# Docker named volume for the data dir, so the database survives restarts and reschedules (persistent, unlike an alloc-relative bind). A fresh volume inherits the image's data-dir ownership, so Postgres can write it.
data_volume = "postgres_data"
# Placement constraints — e.g. pin to one node so the local volume stays put. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true".
constraints = []
# The task resources.
resources = {
cpu = 500
memory = 512
}
| Name | Type | Default | Description |
|---|---|---|---|
| job_name | string | "postgres" | The name of the Nomad job. |
| namespace | string | "default" | The Nomad namespace to deploy into. |
| datacenters | list | ["*"] | The datacenters to deploy to. |
| image | string | "postgres:16-alpine" | The PostgreSQL container image. |
| port | number | 5432 | Host port Postgres listens on (host networking, so it's reachable at <node-ip>:<port>). Pick a free port on the target node. |
| count | number | 1 | Number of instances (keep at 1 — local-disk storage, no built-in replication). |
| db_name | string | "app" | Initial database created on first boot. |
| db_user | string | "app" | Superuser role created on first boot. |
| db_password key | string | "postgres" | Password for db_user. CHANGE THIS — it is baked into the job env. Consider a Nomad variable / Vault instead of a default. |
| data_volume | string | "postgres_data" | Docker named volume for the data dir, so the database survives restarts and reschedules (persistent, unlike an alloc-relative bind). A fresh volume inherits the image's data-dir ownership, so Postgres can write it. |
| constraints | list | [] | Placement constraints — e.g. pin to one node so the local volume stays put. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true". |
| resources | object | {
cpu = 500
memory = 512
} | The task resources. |
No variables match.
PostgreSQL as a host-networked Nomad service with a persistent Docker named
volume, so data survives restarts and reschedules.
nomad-pack registry add nomploy github.com/Nomploy/nomad-packs
nomad-pack run postgres --registry nomploy \
--var db_password=change-me --var db_name=myapp
Or in nomploy: Create → Nomad Pack, pick postgres from the Nomploy registry.
| Variable | Default | Description |
|---|---|---|
job_name |
postgres |
Nomad job name |
image |
postgres:16-alpine |
Container image |
port |
5432 |
Host port (pick a free one per node) |
count |
1 |
Keep at 1 (local-disk storage) |
db_name |
app |
Initial database |
db_user |
app |
Superuser role |
db_password |
postgres |
Change this |
data_volume |
postgres_data |
Docker named volume for /var/lib/postgresql/data |
constraints |
[] |
Pin placement so the local volume stays put |
resources |
{cpu=500, memory=512} |
Task resources |
constraints so it always lands on the node that
holds the volume.