-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
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