Docker Community Forums

Share and learn in the Docker community.

Unable to connect MySQL running on localhost from docker image

docker
dockerhub

(Shailendra Singh) #1

Finally, if your issue has not been addressed elsewhere, running:

  • :whale: :arrow_right:️ Settings :arrow_right:️ Diagnose & Feedback :arrow_right:️ Open Issues.

Dear Team,

I am new in Docker area and trying to explore this. I am not understanding what wrong I am doing or I am not following correct steps to resolve issue:

I have developed a Microservice which connects to my local MySQL, it is working fine. Again I created docker image of that Microservice and trying to run this image through docker. While I am running this docker image, its giving exception saying not able to initialize this connection with MySQL.

Docker is running on Window10 laptop. Below is connection details which works fine, if Microservice is being executed in local machine. When I am trying to run docker image of same microservice in docker environment it is throwing issue as said above.

#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/concretepage
spring.datasource.username=root
spring.datasource.password=Atom@123
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=20
spring.datasource.tomcat.min-idle=15

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE


(Dockerprofessor) #2

How did you solve this Singh?

Best Regards