0

I have tomcat WAR which I want to run inside a Docker having tomcat image. There is a jdbc java Code in the war which access my local mysql from the docker container. But Docker is not able to connect to the local mysql.

I am able to run my war in tomcat locally. I have changed my my.cnf file bind-address to *.

bind-address = *

How can I configure my jdbc url so that it can connect to local mysql inside the Docker. After googling I came to know about the docker.for.mac.host.internal command map to host ip inside docker. I am not sure how to use it.

Zakir saifi
  • 406
  • 4
  • 23

1 Answers1

0

You may connect using Unix Domain Socket by mounting:

volumes:
  -"/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock"

You will also need a compatible JDBC connector, e.g. https://stackoverflow.com/a/31891263/8622794

trozen
  • 1,117
  • 13
  • 13