Cannot connect to Postgres from a SpringBoot app running in a docker container

885 views Asked by At

I have a Spring Boot application that is running in a docker container. From this application I am trying to connect to a Postgres DB that is running in localhost. I am getting Connection refused error.

I tried solution #1 & #3 mentioned in the below post, but that is also not working.

Using Docker to launch web app, can't connect to Postgresql DB?

What I tried so far

  1. Spring Boot application.properties has Postgres url as localhost:5432 and docker run --add-host [dockerhost ip] -it and docker run --net=host -it
  2. Spring Boot application.properties has Postgres url as [dockerhost ip]:5432 and docker run --add-host [dockerhost ip] -it and docker run --net=host -it

Neither of the above is working.

I am using Docker for Mac 1.12.5

0

There are 0 answers