#PostgreSQL, docker conflict

21 messages · Page 1 of 1 (latest)

livid ether
#

Hi guys, please help me!

I try to run docker-compose and have an error: FATAL: password authentication failed for user "postgres"

One interesting fact: if i run an app from a terminal, everything works good.

If i run a docker-compose - fail

There is a photo.

Pls, help me, may be some containers or images may occur an error

Thank you guys!

lofty hare
#

Docker usually sets the password and username via environment variables. You may have to check the Docker compose file to get the right credentials.

lofty hare
#

That's very strange.

livid ether
lofty hare
#

I just meant that it looks like it's being configured correctly from that file.

#

But Postgres is complaining about the wrong credentials

livid ether
#

Yes

lofty hare
#

So it's getting the wrong credentials because it's being given the wrong credentials -- somehow.

livid ether
#

😞

coral timber
#

What value did you use for host?

livid ether
lofty hare
#

In docker compose you connect to different containers via DNS. I wouldn't be surprised if localhost wasn't working.

coral timber
# livid ether localhost

Try this:
For postgres container:
POSTGRES_HOST=postgres_host POSTGRES_DB=postgres POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres

For app connection:
DB_HOST=postgres_host DB_DRIVER=postgres DB_NAME=postgres DB_USER=postgres DB_PASSWORD=postgres

Make sure they are on the same network.

livid ether
livid ether
lofty hare
#

Compose will be creating containers for you. IIRC, they're on the same network by default and services are accessible via DNS by the name of the service.
So in this case, the api container would hit the db container using 'db' as the hostname.
Again, all based on my recollection. YMMV. You may need to check the docs.

coral timber
# livid ether Okay ✅

What @lofty hare said in essence is make the continer's name for the db the hostname.
So if you want to use the parameter I sent earlier your container name would now be post postgres_host, but if you wanna proceed with one you used before, the db_host should be consents_database if I saw it clearly.

Everything should work fine now.

livid ether
#

We restart all containers and etc