mysql两库之间通信_两个Docker容器之间的通讯出现问题

我是Docker的新手,正在尝试将运行在我的 引导示例 docker 容器中的spring boot应用程序连接到一个运行在端口6603上的

mymysql docker 容器中的mysql服务器,两者均在同一台物理计算机上运行。事实是:如果我将spring-boot应用程序连接到

mymysql docker 容器以便与数据库通信,则 不会出现任何错误,并且一切正常。

当 我将spring boot应用程序移动 到 boot-example 容器中并尝试(通过Hibernate)与 mymysql

容器通信时,出现以下错误:

2018-02-05 09:58:38.912 ERROR 1 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_111]

我的Spring Bootapplication.properties是:

server.port=8083

spring.jpa.hibernate.ddl-auto=create-drop

spring.datasource.url=jdbc:mysql://localhost:6603/mydockerdb

spring.datasource.username=root

spring.datasource.password=mypassword

在我的Spring Boot应用在端口8082上的Docker容器中运行之前,它工作正常(在正确构建Docker映像之后):

docker run -it -p 8082:8083 boot-example

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值