ckan / ckan/ckan-docker

The initialisation of DB, error in docker-entrypoint-initdb.d

Open
#247 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
151
Forks
279
PR merge metrics
No merged PRs in 30d

Description

Hello.

It appears, I have found an error in docker-entrypoint-initdb.d (each SHs).
The connection to Postgres is incorrect
`psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER"`

should be
`psql -v ON_ERROR_STOP=1 --username="$POSTGRES_USER" --dbname="$POSTGRES_DB"`
or
`psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"`
[psql](https://www.postgresql.org/docs/17/app-psql.html)

With this CLI
`psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER"`
_"$POSTGRES_USER"_ are handled as _"dbname"_

It works with the default _.env.example_ because
default _'POSTGRES_USER'_ is _'postgres'._
default _'POSTGRES_DB'_ is _"$POSTGRES_USER"_
[postgres Docker Official Image](https://github.com/docker-library/postgres/blob/2925b19f45ceeb8ab8488eec226f2736abf297e1/17/trixie/docker-entrypoint.sh#L234-L238)

So, it works
```
POSTGRES_USER=postgres
POSTGRES_DB=postgres
```
Related issues:
[Won't start up](https://github.com/ckan/ckan-docker/issues/74)
[Docker Compose - Error while starting DB container](https://github.com/ckan/ckan-docker/issues/73)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in docker-entrypoint-initdb.d and inspect each shell script that invokes psql; compare those commands with the .env.example defaults and PostgreSQL's documented argument handling. Verify the scripts with distinct POSTGRES_USER and POSTGRES_DB values, and consider the work done when initialization connects to the configured database rather than treating the user as the database.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, postgresql, shell
Domain
databases, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.