首页 > 技术文章 > 两个docker容器之间无法通信问题

hl15 2020-10-11 22:34 原文

两个docker容器

docker run -it -d --link onlinedb:onlinedb --name app -p 8066:8080 onlineexam/app:v1.0
 

需要加--link  容器名:别名

其中的别名要放到url中

 

另外application.properties中url需设置为:

spring.datasource.url=jdbc:mysql://onlinedb:3306/onlineexam?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&allowMultiQueries=true&serverTimezone=Asia/Shanghai

推荐阅读