Allow docker container to connect to a local/host postgres database

TL;DR Use 172.17.0.0/16 as IP address range, not 172.17.0.0/32. Don’t use localhost to connect to the PostgreSQL database on your host, but the host’s IP instead. To keep the container portable, start the container with the –add-host=database:<host-ip> flag and use database as hostname for connecting to PostgreSQL. Make sure PostgreSQL is configured to listen for … Read more