Trying to enter the correct user and password set for the database fails with the extremely helpful error "login failed". As listed below, I have tried all of the common solutions for this issue as found around here, no dice yet.
psql
from the HOST machine and within database container using credentials below.show listen_addresses;
is "*".PHP_PG_ADMIN_SERVER_PORT
, no difference.netstat
confirms the database is listening on the right port on the host.PHP_PG_ADMIN_SERVER_HOST
.docker-compose.yaml
networks:
centurion:
name: centurion-net
services:
benard:
image: postgres:latest
restart: always
volumes:
- /opt/containers/benard/persist/data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=pg
- POSTGRES_USER=pg
- POSTGRES_PASSWORD=password
ports:
- "5432:5432"
networks:
- centurion
benard_ui:
depends_on:
- benard
restart: always
image: dockage/phppgadmin:latest
ports:
- "8200:80"
environment:
- PHP_PG_ADMIN_SERVER_DESC=BENARD
- PHP_PG_ADMIN_SERVER_HOST=benard
- PHP_PG_ADMIN_SERVER_PORT=5432
- PHP_PG_ADMIN_SERVER_SSL_MODE=allow
- PHP_PG_ADMIN_SERVER_DEFAULT_DB=template1
- PHP_PG_ADMIN_SERVER_PG_DUMP_PATH=/usr/bin/pg_dump
- PHP_PG_ADMIN_SERVER_PG_DUMPALL_PATH=/usr/bin/pg_dumpall
- PHP_PG_ADMIN_DEFAULT_LANG=auto
- PHP_PG_ADMIN_AUTO_COMPLETE=default on
- PHP_PG_ADMIN_EXTRA_LOGIN_SECURITY=false
- PHP_PG_ADMIN_OWNED_ONLY=false
- PHP_PG_ADMIN_SHOW_COMMENTS=true
- PHP_PG_ADMIN_SHOW_ADVANCED=false
- PHP_PG_ADMIN_SHOW_SYSTEM=false
- PHP_PG_ADMIN_MIN_PASSWORD_LENGTH=1
- PHP_PG_ADMIN_LEFT_WIDTH=200
- PHP_PG_ADMIN_THEME=default
- PHP_PG_ADMIN_SHOW_OIDS=false
- PHP_PG_ADMIN_MAX_ROWS=30
- PHP_PG_ADMIN_MAX_CHARS=50
- PHP_PG_ADMIN_USE_XHTML_STRICT=false
- PHP_PG_ADMIN_HELP_BASE=http://www.postgresql.org/docs/%s/interactive/
- PHP_PG_ADMIN_AJAX_REFRESH=3
networks:
- centurion
If you docker exec
into the phppgadmin container and try to connect to postgres with the psql
command, you'll see:
psql: SCRAM authentication requires libpq version 10 or above
And originally I was going to write about how to configure recent versions of Postgres to use md5 authentication instead, but then I discovered that was pointless:
The version of phppgadmin in the dockage/phppgadmin
image only supports Postgres up to version 12. Using anything more recent results in the error message:
Version of PostgreSQL not supported. Please upgrade to version or later.
It looks like that image was last updated over four years ago, so you may want to find a more recent alternative (or build your own).
With the above limitation in mind, a working configuration looks like this:
volumes:
postgres_data:
services:
postgres:
image: docker.io/postgres:12
volumes:
- "postgres_data:/var/lib/postgresql/data"
environment:
POSTGRES_USER: "$POSTGRES_USER"
POSTGRES_PASSWORD: "$POSTGRES_PASSWORD"
command:
- postgres
- -c
- log_connections=on
phppgadmin:
image: docker.io/dockage/phppgadmin:latest
environment:
PHP_PG_ADMIN_SERVER_DESC: postgres
PHP_PG_ADMIN_SERVER_HOST: postgres
PHP_PG_ADMIN_SERVER_PORT: "5432"
ports:
- "8000:80"
Assuming that I have the following .env
file:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
Then I can docker-compose up
, connect to http://localhost:8000, and login as user postgres
with password secret
.