Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres database is uninitialized and superuser password is not specified #28

Closed
jmz-b opened this issue Mar 16, 2020 · 3 comments
Closed

Comments

@jmz-b
Copy link

jmz-b commented Mar 16, 2020

A recent update to the official postgres docker image breaks xnat-docker-compose out the box, causing it to fail with the following error.

$ docker-compose up
Starting xnat-docker-compose_xnat-db_1 ... done
Recreating xnat-docker-compose_xnat-web_1 ... done
Creating xnat-docker-compose_xnat-nginx_1 ... done
Attaching to xnat-docker-compose_xnat-db_1, xnat-docker-compose_xnat-web_1, xnat-docker-compose_xnat-nginx_1
xnat-db_1     | Error: Database is uninitialized and superuser password is not specified.
xnat-db_1     |        You must specify POSTGRES_PASSWORD for the superuser. Use
xnat-db_1     |        "-e POSTGRES_PASSWORD=password" to set it in "docker run".
xnat-db_1     | 
xnat-db_1     |        You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections
xnat-db_1     |        without a password. This is *not* recommended. See PostgreSQL
xnat-db_1     |        documentation about "trust":
xnat-db_1     |        https://www.postgresql.org/docs/current/auth-trust.html
xnat-web_1    | psql: could not translate host name "xnat-db" to address: Name does not resolve
xnat-web_1    | Postgres is unavailable - sleeping

One simple work around (which it appears you are aware of by looking at some of the more recent code in branches other than master) is to add the following lines to the xnat-db definition in docker-compose.yml:

    environment:
      POSTGRES_HOST_AUTH_METHOD: trust

However this is not really best practice security wise, as it means any other service on the same docker network can get access to the xnat postgres database without authentication.

Ideally I think the xnat-db image should be pre-configured with a password using the POSTGRES_PASSWORD environment variable, and the the xnat-web container should be made aware of this value and use it when connecting.

I would love to hear your thoughts on this.

@jvsoest
Copy link

jvsoest commented Mar 17, 2020

experienced the same issue today. What did resolve it for me (temporarily) is updating the postgres/Dockerfile on line 1: FROM postgres:9.4.25-alpine

Including the patching to the previous version of postgres 9.4 did resolve it (version 25).
In the development branches of this repository I do see that they are bumping to postgres 12.xx in newer versions. So I think this is a breaking change at Postgres.

@rherrick
Copy link
Contributor

rherrick commented Mar 17, 2020 via email

rherrick pushed a commit that referenced this issue Jun 23, 2020
Setting POSTGRES_PASSWORD with default, introduced other env vars, closes #20, closes #28.
@dmd
Copy link
Contributor

dmd commented Oct 23, 2020

Why is this closed? The issue is not resolved in HEAD, at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants