1

I am creating a Spring MVC application using ORM as a Hibernate, a web server like tomcat, and a database as a MYSQL. I ran it in my local system its working fine and using docker desktop, I try to containerize my application part only as a docker container and keep my DB in local itself like localhost and I try to run my docker container is sowing some hibernate error seems like my containerized application not able to connect to my local DB

FROM tomcat:8.5.31-jre8
RUN rm -rvf /usr/local/tomcat/webapps/ROOT
ADD  /target/Ecom_XML_Configuration.war /usr/local/tomcat/webapps/ROOT.war
CMD ["catalina.sh", "run"]
EXPOSE 8080

Connection string :jdbc:mysql://localhost:3306/ecom?useSSL=false&serverTimezone=UTC

Error : Unable to open JDBC Connection for DDL execution

  • The container separately believes it is `localhost`, so it's trying to connect to itself and not the database server. If you can also run the database in a container (maybe using Docker Compose) that could be the easiest approach, but the linked question describes host-platform-specific approaches for calling back to the host system. – David Maze Feb 14 '22 at 14:18

0 Answers0