Skip to content

Set random password if POSTGRES_PASSWORD was not provided #1199

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

Closed
EugenKon opened this issue Feb 20, 2024 · 4 comments
Closed

Set random password if POSTGRES_PASSWORD was not provided #1199

EugenKon opened this issue Feb 20, 2024 · 4 comments

Comments

@EugenKon
Copy link

Actually this is not required to provide this password. In pg_hba.conf file by default we trust connections via socket, thus user in any time can login and ALTER ROLE postgres. So this is secure and less error prone solution.

@yosifkit
Copy link
Member

yosifkit commented May 6, 2025

Sorry for the slow response. I'm not sure I understand the ask, but we don't want to add more magic behavior to the entrypoint at this time.

The user must set a password via POSTGRES_PASSWORD or set POSTGRES_HOST_AUTH_METHOD to trust (very insecure). This is mentioned in the docs from Docker Hub.

@yosifkit yosifkit closed this as completed May 6, 2025
@EugenKon
Copy link
Author

EugenKon commented May 7, 2025

@yosifkit I mean that by entry we are able to not require POSTGRES_PASSWORD. This ENV could be not mandatory. If not provided the script could just setup random password into it.

Thanks for the link. I do not see any mentions that it is "insecure" there. Even the link from that read me says it could be Ok. https://www.postgresql.org/docs/14/auth-trust.html. Though it looks like it refers to the outdated documentation. Should it be current?

@yosifkit
Copy link
Member

yosifkit commented May 7, 2025

We moved to explicitly require a password in #658. We don't want to reverse that with an automatic random password.

trust mode in POSTGRES_HOST_AUTH_METHOD is insecure because it means anyone can connect without a password and get access to the database, so if you expose the PostgreSQL port to the network (like via -p 5432:5432 on docker run or ports: [ "5432:5432" ] in compose.yml) it can and will likely be "hacked".

@EugenKon
Copy link
Author

EugenKon commented May 7, 2025

It would be nice to have this mentioned at that document. Thanks.

*I understand this is obvious for experienced users but this could be useful for a new one.

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

2 participants