Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 无法从docker容器中运行的SpringBoot应用程序连接到Postgres_Spring Boot_Postgresql 9.1_Docker For Mac - Fatal编程技术网

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

Spring boot 无法从docker容器中运行的SpringBoot应用程序连接到Postgres,spring-boot,postgresql-9.1,docker-for-mac,Spring Boot,Postgresql 9.1,Docker For Mac,我有一个SpringBoot应用程序,它运行在docker容器中。我试图从这个应用程序连接到一个在本地主机上运行的Postgres DB。 我收到连接被拒绝错误 我尝试了下面帖子中提到的解决方案1和3,但也不起作用 到目前为止我试过什么 Spring Boot application.properties的Postgres url为localhost:5432和 docker运行--添加主机[dockerhost ip]-it和docker运行--net=host-it Spring Boot

我有一个SpringBoot应用程序,它运行在docker容器中。我试图从这个应用程序连接到一个在本地主机上运行的Postgres DB。 我收到连接被拒绝错误

我尝试了下面帖子中提到的解决方案1和3,但也不起作用

到目前为止我试过什么

  • Spring Boot application.properties的Postgres url为localhost:5432和 docker运行--添加主机[dockerhost ip]-it和docker运行--net=host-it
  • Spring Boot application.properties的Postgres url为[dockerhost ip]:5432 docker run--add host[dockerhost ip]-it和docker run--net=host-it
  • 上述两项都不起作用

    我正在使用Mac 1.12.5的Docker