I have a few problems connecting to PostgreSQL from my Python application. PostgreSQL is outside the container because it's an existing database.
From outside the container, the database looks accessible:
$ nmap -p 5432 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-05 18:33 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00014s latency).
Other addresses for localhost (not scanned): ::1
PORT STATE SERVICE
5432/tcp open postgresql
Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds
But from inside:
bash-4.4# nmap -p 5432 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-05 16:34 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000040s latency).
Other addresses for localhost (not scanned): ::1
PORT STATE SERVICE
5432/tcp closed postgresql
Nmap done: 1 IP address (1 host up) scanned in 0.41 seconds
I could not find any similar issues.