dokploy_postgres (Resource)
A PostgreSQL database service in a Dokploy environment.
Example Usage
resource "dokploy_postgres" "example" {
name = "app-db"
environment_id = [for e in dokploy_project.example.environments : e.id if e.name == "production"][0]
database_name = "app"
database_user = "app"
database_password = var.db_password # use a sensitive variable
docker_image = "postgres:16-alpine"
env = <<-EOT
TZ=UTC
EOT
}
Schema
Required
database_name(String) Name of the PostgreSQL database.database_password(String, Sensitive) PostgreSQL password. Changing it triggers a redeploy.database_user(String) PostgreSQL user.environment_id(String) Id of the environment this service lives in (seedokploy_project.environments).name(String) Display name of the database service.
Optional
app_name(String) Dokploy-internal app name; generated by the server when omitted.deploy_on_change(Boolean) Deploy after create and after changes to deploy-triggering attributes. Defaults totrue.deployment_timeout(String) How long to wait for a triggered deployment to reach a terminal status, as a Go duration string. Defaults to"15m". On timeout the apply fails but the server-side deployment keeps running.description(String) Free-form description.detach_dokploy_network(Boolean) Detach the shareddokploy-networkfrom this service. Defaults tofalse. Only meaningful together withnetwork_ids; applied on the next deploy.docker_image(String) Postgres docker image, e.g.postgres:16-alpine. Server default when omitted.env(String) Extra environment variables in Dokploy’s native multilineKEY=valueformat. Use Terraform sensitive variables for secret values. Omitting this attribute and setting it to “” are indistinguishable on read — both come back null. Use omission, not “”, to clear it.external_port(Number) Host port to expose PostgreSQL on. Unset keeps the database internal-only.network_ids(Set of String) Ids of Docker networks (Dokploy network records) to attach this service to. Applied on the next deploy. Omit to keep only the defaultdokploy-network. An empty set is not valid - omit the attribute instead.server_id(String) Remote server to run the service on. Defaults to the Dokploy host.
Read-Only
created_at(String) Creation timestamp (server-side).id(String) Postgres service id.status(String) Service status reported by Dokploy.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dokploy_postgres.example <postgresId>