You have to do 2 things in order to allow your container to access your host's postgresql database
- Make your postgresql listen to an external ip address
- Let this client ip (your docker container) access your postgresql database with a given user
Obs: By "Host" here I mean "the server where docker is running on".
Find your postgresql.conf (in case you don't know where it is)
$ sudo find / -type f -name postgresql.conf