Issue with PosgreSQL Docker

Hello,

I have the following docker-compose.yml file:

version: "3.9"
services:
    db:
        image: postgres:9.4
        environment:
            - POSTGRES_PASSWORD=password
    result:
        image: result
        ports:
            - 8080:80

When I execute “docker-compose up” I get the following error and don’t understand why?

root-db-1      | FATAL:  password authentication failed for user "postgres"
root-db-1      | DETAIL:  Connection matched pg_hba.conf line 95: "host all all all md5"
root-result-1  | Waiting for db

If I add “POSTGRES_HOST_AUTH_METHOD=trust” all is OK, but I guess it is an incorrect solution

Hello @linuxmemorywork,
make sure that you define the right password and password

environment:
    POSTGRES_PASSWORD: <password>
    POSTGRES_USER: <user name>

And yes, For simplicity, we use POSTGRES_HOST_AUTH_METHOD=trust to allow passwordless access to Postgres in real production deployment, and that option is not recommended. And instead of that configure proper credentials using POSTGRES_PASSWORD and POSTGRES_USER

Thanks,
KodeKloud Support