Mysql container in Docker bridge network cannot be connected

  docker, question

Springboot application reported an error when accessing the database:

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

Enter the container where the SpringBoot application is located myapp-in-net to ping the mysql-test container:

ping mysql-test
 PING mysql-test ( 56 data bytes
 64 bytes from seq=0 ttl=64 time=0.308 ms
 64 bytes from seq=1 ttl=64 time=0.186 ms of SpringBoot (I used a multi-data source configuration so I customized the variable name):

spring.datasource.test1.driverClassName = com.mysql.jdbc.Driver
 spring.datasource.test1.url = jdbc:mysql://  useUnicode=true&characterEncoding=utf-8
 spring.datasource.test1.username = root
 spring.datasource.test1.password = root

This is docker network information

$ sudo docker network inspect my-net
 "Name": "my-net",
 "Id": "9351cf7ce0dc4b2f1d7f259ed6674eeda27997b375e113648e589d9ce35939a7",
 "Created": "2018-02-17T08:45:01.476631336Z",
 "Scope": "local",
 "Driver": "bridge",
 "EnableIPv6": false,
 "IPAM": {
 "Driver": "default",
 "Options": {},
 "Config": [
 "Subnet": "",
 "Gateway": ""
 "Internal": false,
 "Attachable": false,
 "Ingress": false,
 "ConfigFrom": {
 "Network": ""
 "ConfigOnly": false,
 "Containers": {
 "1bc6f9393c45f7aa405eb837d33a924b4310321cca855655247e657d1697c034": {
 "Name": "redis-in-net",
 "EndpointID": "af77c4b6d91698965605a42d2d8ad05e67d2671c1ff0a03a458630e5998203f3",
 "MacAddress": "02:42:ac:12:00:02",
 "IPv4Address": "",
 "IPv6Address": ""
 "39863741c672d21a715f54788bcde08d85239613b205563eb425c66894ab01a2": {
 "Name": "busybox2",
 "EndpointID": "34ead20723641dbd5067b82f1d2ea1f5eddccf84e7eb0272b2a622a3fd85edf2",
 "MacAddress": "02:42:ac:12:00:06",
 "IPv4Address": "",
 "IPv6Address": ""
 "8cb8107bcf1a456392971eac3a3926accfe55d1ed1a428fc6d33cd1ccdeec4f5": {
 "Name": "mysql-test",
 "EndpointID": "6458537bce07ce59dad7c46175865c80622bb27346455e0945c163731081b94c",
 "MacAddress": "02:42:ac:12:00:04",
 "IPv4Address": "",
 "IPv6Address": ""
 "d90df0352762b29ea9381003dd48ec230ae916f2e1507b20d1f79648fd131c52": {
 "Name": "myapp-in-net",
 "EndpointID": "594a039bc68d31acc11d0a6988bcc75c30c84a77aa5accfa759b1e2cc89aa203",
 "MacAddress": "02:42:ac:12:00:03",
 "IPv4Address": "",
 "IPv6Address": ""
 "Options": {},
 "Labels": {}

Strangely, the redis container access in the same network does not have the problem of connection failure. Configuration:
 # Redis Server Connection Port

Telnet try to connect