I'm trying to run bitnami/postgresql:16.2.0 docker image, but no luck.
Here are the steps:
- stop container, delete container, clean "data" directory
docker stop RR15 ; docker rm RR15 ; rm -rf ~/containers/postgres16.2/data/
here is my custom
pg_hba.conf(only 2 lines not commented):host all all 0.0.0.0/0 md5
host all all 127.0.0.1/32 md5
run docker
docker run --name RR15 -p 5432:5432 -v ~/containers/postgres16.2:/bitnami/postgresql -v ~/containers/postgres16.2/conf:/bitnami/postgresql/conf -e POSTGRESQL_USERNAME=user1 -e POSTGRESQL_PASSWORD=pwduser1 -e POSTGRESQL_DATABASE=postgres -e POSTGRESQL_POSTGRES_PASSWORD=postgres bitnami/postgresql:16.2.0
so
- POSTGRESQL_USERNAME=user1
- POSTGRESQL_PASSWORD=pwduser1
- POSTGRESQL_DATABASE=postgres
- POSTGRESQL_POSTGRES_PASSWORD=postgres. (more info about this param)
As soon as I execute the command it starts and stops, looks fine ... no issues, full detail here:
postgresql 19:03:04.46 INFO ==>
postgresql 19:03:04.46 INFO ==> Welcome to the Bitnami postgresql container
postgresql 19:03:04.46 INFO ==> Subscribe to project updates by watching https://github.com/bitnami/containers
postgresql 19:03:04.46 INFO ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
postgresql 19:03:04.47 INFO ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
postgresql 19:03:04.47 INFO ==>
postgresql 19:03:04.48 INFO ==> ** Starting PostgreSQL setup **
postgresql 19:03:04.50 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgresql 19:03:04.52 INFO ==> Loading custom pre-init scripts...
postgresql 19:03:04.52 INFO ==> Initializing PostgreSQL database...
postgresql 19:03:04.53 INFO ==> Custom configuration /opt/bitnami/postgresql/conf/postgresql.conf detected
postgresql 19:03:04.53 INFO ==> Custom configuration /opt/bitnami/postgresql/conf/pg_hba.conf detected
postgresql 19:03:08.14 INFO ==> Starting PostgreSQL in background...
postgresql 19:03:08.26 INFO ==> Changing password of postgres
postgresql 19:03:08.27 INFO ==> Stopping PostgreSQL...
waiting for server to shut down.... done
server stopped
I'm stating the container again and so far it looks good:
2024-03-18 12:03:14 postgresql 19:03:14.78 INFO ==>
2024-03-18 12:03:14 postgresql 19:03:14.79 INFO ==> Welcome to the Bitnami postgresql container
2024-03-18 12:03:14 postgresql 19:03:14.79 INFO ==> Subscribe to project updates by watching https://github.com/bitnami/containers
2024-03-18 12:03:14 postgresql 19:03:14.79 INFO ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
2024-03-18 12:03:14 postgresql 19:03:14.79 INFO ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
2024-03-18 12:03:14 postgresql 19:03:14.79 INFO ==>
2024-03-18 12:03:14 postgresql 19:03:14.81 INFO ==> ** Starting PostgreSQL setup **
2024-03-18 12:03:14 postgresql 19:03:14.82 INFO ==> Validating settings in POSTGRESQL_* env vars..
2024-03-18 12:03:14 postgresql 19:03:14.83 INFO ==> Loading custom pre-init scripts...
2024-03-18 12:03:14 postgresql 19:03:14.83 INFO ==> Initializing PostgreSQL database...
2024-03-18 12:03:14 postgresql 19:03:14.84 INFO ==> Custom configuration /opt/bitnami/postgresql/conf/postgresql.conf detected
2024-03-18 12:03:14 postgresql 19:03:14.84 INFO ==> Custom configuration /opt/bitnami/postgresql/conf/pg_hba.conf detected
2024-03-18 12:03:14 postgresql 19:03:14.86 INFO ==> Deploying PostgreSQL with persisted data...
2024-03-18 12:03:14 postgresql 19:03:14.86 INFO ==> Loading custom scripts...
2024-03-18 12:03:14 postgresql 19:03:14.87 INFO ==> ** PostgreSQL setup finished! **
2024-03-18 12:03:14
2024-03-18 12:03:14 postgresql 19:03:14.88 INFO ==> ** Starting PostgreSQL **
2024-03-18 12:03:14 2024-03-18 19:03:14.901 GMT [1] LOG: pgaudit extension initialized
2024-03-18 12:03:14 2024-03-18 19:03:14.921 GMT [1] LOG: starting PostgreSQL 16.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-03-18 12:03:14 2024-03-18 19:03:14.922 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-03-18 12:03:14 2024-03-18 19:03:14.922 GMT [1] LOG: listening on IPv6 address "::", port 5432
2024-03-18 12:03:14 2024-03-18 19:03:14.925 GMT [1] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-03-18 12:03:14 2024-03-18 19:03:14.934 GMT [55] LOG: database system was shut down at 2024-03-18 19:03:08 GMT
2024-03-18 12:03:14 2024-03-18 19:03:14.944 GMT [1] LOG: database system is ready to accept connections
Now I'm trying to connect as user1 with pwduser1 to postgres:
2024-03-18 12:05:49 2024-03-18 19:05:49.737 GMT [62] FATAL: password authentication failed for user "user1"
2024-03-18 12:05:49 2024-03-18 19:05:49.737 GMT [62] DETAIL: Role "user1" does not exist.
2024-03-18 12:05:49 Connection matched file "/opt/bitnami/postgresql/conf/pg_hba.conf" line 96: "host all all 0.0.0.0/0 md5"
Same for postgres with password "postgres" to postgres DB:
2024-03-18 12:04:33 2024-03-18 19:04:33.260 GMT [60] FATAL: password authentication failed for user "postgres"
2024-03-18 12:04:33 2024-03-18 19:04:33.260 GMT [60] DETAIL: User "postgres" has no password assigned.
2024-03-18 12:04:33 Connection matched file "/opt/bitnami/postgresql/conf/pg_hba.conf" line 96: "host all all 0.0.0.0/0 md5"
I'm not sure what's wrong here, and I'm trying to find the cause. I could use a bandage-like solution, such as connecting and changing passwords, or using "trust" for localhost. However, I prefer to create a correct Docker command.
I had the same setup for v15.4, and it worked just fine. It feels like the issue is connected with volume mapping.
Any help is appreciated!
update
After looking at the Rabban Keyak's answer I played a bit more and find out that if I exclude pg_hba.conf everything works as it should
The package itself generates this content for pg_hba.conf:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
However, changing the content to this ^^ doesn't help.


Not like instantly, but in about 15 minutes i've done repeating your case.
Differeces:
podmaninstead ofdocker(doesn't have the last one installed nearby)--mountinstead of-v, and it's optionU=trueto achieve apropriate rights for directoriesscram-sha-256hash instead ofmd5After all of that i was able to connect the server using psql.
The image you are using is fine seems. The problem seems like somewhere behind of my changes.