Even if postgres exposed, the localhost reference used is the container localhost not the host where postgres exposed the port. You need to use a different hostname if you want to access the database via the host: https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66
My 2 cents is to not follow that guide and just find a docker-compose example script and use that, for example like this one: Docker Compose setup for Elixir, Phoenix, and Postgres · GitHub . It will make your life easier as to connect the database you can just use db as hostname, no further setup required.






















