Can't connect to the socket for mysql running under docker from the host?

610 Views Asked by At

I have mySQL running in a container. It and my app (in a different Docker container) seem to run fine. I am now trying to use Jaspersoft's iReport to develop a report with. I have managed to get iReport up and running on the host, Ubuntu. The problem is accessing the database from the host.

This is required to use iReport and I just can't seem to get the connection working. I tried looking at the mysql socket, but it is not in the normal place, since mySQL is in a Docker Container. I am also working on getting JasperReports server to run in another container. But my problem is connecting from the host to the mySQL database running in Docker via an JDBC connection.

here is the docker-compose.yml https://drive.google.com/open?id=1CY_tPmnot3zSab0BtLE1fJUC7sdD2tyA

The connection that iReports has chosen is jdbc:mysql://localhost/substantiator. When I try to "test" this with the iReport database test button I get a popup that asks for password. I have tried using the same user/password combo that works from my app. It fails with: SQL problems: Communication Link Failure. In researching this I am asked to update the mySQL socket path in a mysql cnf file. But in my installation the socket file doesn't exist (because it it in docker?). So I am stumped. I am considering moving over to mariaDB. Any ideas?

1

There are 1 best solutions below

0
Tomáš Mafi Vinduška On

Hi your MySql container expose port 3306 from host machine you can connect using localhost,but for some external service you need to use host machine IP address and also make sure port 3306 is exposed to outside.