Skip to content

Conversation

@s01ipsist
Copy link
Contributor

@s01ipsist s01ipsist commented Nov 7, 2025

Adds support for Postgres 18 by adding conditional logic to set the data volume path differently for before/after v 18, as guided by https://hub.docker.com/_/postgres

The defined VOLUME was changed in 18 and above to /var/lib/postgresql. Mounts and volumes should be targeted at the updated location

Important Note: (for PostgreSQL 17 and below) Mount the data volume at /var/lib/postgresql/data and not at /var/lib/postgresql because mounts at the latter path WILL NOT PERSIST database data when the container is re-created

Fixes #364
Replaces #358 / #367

Not sure if this needs to be fixed or not, but there's a subtle functional change in the result with this code as is.

PostgreSQL Database directory appears to contain a database; Skipping initialization

v18 triggers the path with message output

PostgreSQL init process complete; ready for start up.

and stops the container.

@josegonzalez
Copy link
Member

Whats the entire output of an initial dokku postgres:create with v18 today?

@s01ipsist
Copy link
Contributor Author

Whats the entire output of an initial dokku postgres:create with v18 today?

ubuntu@multidokku25:~$ dokku plugin:list | grep postgres
  postgres             1.45.0 enabled    dokku postgres service plugin
ubuntu@multidokku25:~$ dokku postgres:create pg18test --image-version 18.1
18.1: Pulling from library/postgres
b89cf3ec7a3e: Pull complete
3d40ad1ee517: Pull complete
5e86690e08b4: Pull complete
36aea44977d6: Pull complete
af5b2941599b: Pull complete
e808f1e529cf: Pull complete
07c5a27f4144: Pull complete
d84932fbe51d: Pull complete
87e5f1d7b994: Pull complete
477d35ab7c57: Pull complete
c598951473cf: Pull complete
55bb4e0a9b60: Pull complete
4aee7b1337ee: Pull complete
Digest: sha256:5ec39c188013123927f30a006987c6b0e20f3ef2b54b140dfa96dac6844d883f
Status: Downloaded newer image for postgres:18.1
docker.io/library/postgres:18.1
       Waiting for container to be ready
       Creating container database
       Securing connection to database
ubuntu@multidokku25:~$ dokku postgres:info pg18test
=====> pg18test postgres service information
       Config dir:          /var/lib/dokku/services/postgres/pg18test/data
       Config options:
       Data dir:            /var/lib/dokku/services/postgres/pg18test/data
       Dsn:                 postgres://postgres:2f6f0c006b10032d2279fa0314fccb51@dokku-postgres-pg18test:5432/pg18test
       Exposed ports:       -
       Id:                  fe1988ffa73c5e1b33e477ba5303ac60bede64f53aa246ad64fc8943b3c4f43e
       Internal ip:
       Initial network:
       Links:               -
       Post create network:
       Post start network:
       Service root:        /var/lib/dokku/services/postgres/pg18test
       Status:              exited
       Version:             postgres:18.1

@josegonzalez
Copy link
Member

Atm it looks like all tests fail because the :create command fails. That needs to work and create a running container. What changes would be necessary to do that?

@s01ipsist
Copy link
Contributor Author

Atm it looks like all tests fail because the :create command fails. That needs to work and create a running container. What changes would be necessary to do that?

Have added a change that tries to ensure the container is running after create

@josegonzalez
Copy link
Member

Yeah create still exits 0. I'll have to take a look at this tomorrow and see whats going on locally.

@s01ipsist
Copy link
Contributor Author

s01ipsist commented Dec 4, 2025

I see now that it's the call in scripts/enable_ssl.sh which errors (silently)

bash: line 5: cd: /var/lib/postgresql/data: No such file or directory

so the following call in functions to
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"
never gets called.

This "Securing connection to database" section needs a matching fix 🤔

@s01ipsist
Copy link
Contributor Author

We can use the PGDATA env var set in the upstream image.
https://github.com/docker-library/postgres/blob/9c515320bc6aa1243585763eb1696118969ffef0/Dockerfile-alpine.template#L221
This works for 18 and <18.

$ dokku postgres:create postgres18_test --image-version 18.0
       Waiting for container to be ready
       Creating container database
       Securing connection to database
=====> Postgres container created: postgres18_test
=====> postgres18_test postgres service information
       Config dir:          /var/lib/dokku/services/postgres/postgres18_test/data
       Config options:
       Data dir:            /var/lib/dokku/services/postgres/postgres18_test/data
       Dsn:                 postgres://postgres:7b5e5f8b9ce4bc429a36a984051f13f3@dokku-postgres-postgres18-test:5432/postgres18_test
       Exposed ports:       -
       Id:                  fb594e1636fec8de24f39a1328a08f9359affd54b0ee8c502ea188b6ff901ac0
       Internal ip:         172.17.0.7
       Initial network:
       Links:               -
       Post create network:
       Post start network:
       Service root:        /var/lib/dokku/services/postgres/postgres18_test
       Status:              running
       Version:             postgres:18.0
$ dokku postgres:connect postgres18_test
psql (18.0 (Debian 18.0-1.pgdg13+3))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off, ALPN: postgresql)
Type "help" for help.

postgres18_test=# \q

This gets bumped during a release
@josegonzalez josegonzalez merged commit bf9eb4b into dokku:master Dec 4, 2025
@josegonzalez
Copy link
Member

Thanks for the pull request!

@s01ipsist s01ipsist deleted the postgres18 branch December 4, 2025 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volume Path changed for postgres v18+

2 participants