Description
The exec_sql function in docker-entrypoint.sh hardcodes PGPASSWORD=password and -U postgres when connecting via psql. This means that when DOLTGRES_USER is set to a custom value, init scripts in /docker-entrypoint-initdb.d/ silently fail because the postgres user no longer exists.
Reproduction
# docker-compose.yml
services:
db:
image: dolthub/doltgresql:latest
environment:
DOLTGRES_USER: myuser
DOLTGRES_PASSWORD: mypassword
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
-- init.sql
CREATE TABLE test (id UUID PRIMARY KEY DEFAULT gen_random_uuid());
Result: The entrypoint reports running the init script, but the SQL never executes because psql -U postgres with PGPASSWORD=password fails authentication. The exec_sql retry loop silently retries until timeout or until a non-matching error pattern is hit.
Root cause
In docker-entrypoint.sh, the exec_sql function (around line 90):
output=$(PGPASSWORD=password psql -h 127.0.0.1 -U postgres -c "$query" 2>&1)
This should use the configured DOLTGRES_USER and DOLTGRES_PASSWORD values instead of hardcoded defaults.
Expected behavior
exec_sql should connect using the credentials from DOLTGRES_USER/DOLTGRES_PASSWORD (or their POSTGRES_* equivalents), falling back to postgres/password only if unset.
Workaround
Don't set DOLTGRES_USER/DOLTGRES_PASSWORD. Use the default postgres/password credentials and create custom users in the init script instead.
Environment
- DoltgreSQL version: 0.54.10
- Docker image:
dolthub/doltgresql:latest
Description
The
exec_sqlfunction indocker-entrypoint.shhardcodesPGPASSWORD=passwordand-U postgreswhen connecting via psql. This means that whenDOLTGRES_USERis set to a custom value, init scripts in/docker-entrypoint-initdb.d/silently fail because thepostgresuser no longer exists.Reproduction
Result: The entrypoint reports running the init script, but the SQL never executes because
psql -U postgreswithPGPASSWORD=passwordfails authentication. Theexec_sqlretry loop silently retries until timeout or until a non-matching error pattern is hit.Root cause
In
docker-entrypoint.sh, theexec_sqlfunction (around line 90):output=$(PGPASSWORD=password psql -h 127.0.0.1 -U postgres -c "$query" 2>&1)This should use the configured
DOLTGRES_USERandDOLTGRES_PASSWORDvalues instead of hardcoded defaults.Expected behavior
exec_sqlshould connect using the credentials fromDOLTGRES_USER/DOLTGRES_PASSWORD(or theirPOSTGRES_*equivalents), falling back topostgres/passwordonly if unset.Workaround
Don't set
DOLTGRES_USER/DOLTGRES_PASSWORD. Use the defaultpostgres/passwordcredentials and create custom users in the init script instead.Environment
dolthub/doltgresql:latest