Docker Community Forums

Share and learn in the Docker community.

Tomcat in docker cannot connect to remote MySQL

I have two servers. The first server installs MySQL database V8, and the second server installs docker Tomcat. An error occurred when Tomcat in docker of the second server connected MySQL of the first server.How to solve it?

Tomcat Log Error:
01-Mar-2020 10:45:21.615 SEVERE [main] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [jfinal]
java.lang.RuntimeException: Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin.
com.mysql.cj.jdbc.exceptions.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.

01-Mar-2020 10:45:21.615 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
01-Mar-2020 10:45:21.615 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context startup failed due to previous errors
01-Mar-2020 10:45:21.629 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
01-Mar-2020 10:45:21.629 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
01-Mar-2020 10:45:21.630 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@11.0.6/java.lang.Object.wait(Native Method)