The PostgreSQL database is just installed directly into the linux host machine (not as docker container).
In a docker container (built with docker compose) I have an application that needs to connect to the database.
The client container needs to be on a docker bridge network and cannot be on the host network directly because it needs to reach other containers on the bridge network.
I connect to the Postgres database using the
host.docker.internal
hostname as described here.
From within that container I can reach the database no problem that way. But PostgreSQL needs to allow this connection in pg_hba.conf
or else I get the error:
no pg_hba.conf entry for host "172.22.0.3"
Of course I can add that IP address to pg_hba.conf
like done here but that won't give me a very stable solution because the IP address will not always be the same.
What would be the best practice? Allow all connection from 172...* ? Or...?