无法从Docker容器中运行的SpringBoot应用程序连接到Postgres

时间:2017-01-05 17:58:21

标签: spring-boot postgresql-9.1 docker-for-mac

我有一个在Docker容器中运行的Spring Boot应用程序。从这个应用程序,我试图连接到在localhost中运行的Postgres数据库。 我收到Connection拒绝错误。

我尝试过解决方案#1& #3中提到了#3,但这也无效。

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

到目前为止我尝试了什么

  1. Spring Boot application.properties将Postgres url作为localhost:5432和 docker run --add-host [dockerhost ip] -it和docker run --net = host -it
  2. Spring Boot application.properties将Postgres url作为[dockerhost ip]:5432 和docker run --add-host [dockerhost ip] -it和docker run --net = host -it
  3. 上述两种方法都不起作用。

    我正在使用Docker for Mac 1.12.5

0 个答案:

没有答案
相关问题