I have a Spring Boot application running inside of a Dockers container. The application offers REST endpoints, which can successfully be called from the host machine using http://localhost:8080/endpoint. Previously, when this application ran on the host machine and not within Dockers, I could call the local MariaDB using jdbc:mariadb://localhost:3308/fi?user=userName&password=thePassword from within the application. Now that the application is running inside of Dockers, the connection returns the error: "Could not connect to address=(host=localhost)(port=3308)(type=master) : Connection refused (Connection refused)"
The code snippet making the connection is as follows:
Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3308/fi?user=username&password=thePassword");
Statement stmt = connection.createStatement();
String query = "";
ResultSet rs = stmt.executeQuery("SELECT * ....;");
I already have the 8080 port published to accept the REST calls from the host machine, and have tried to publish or expose the 3308 port to allow for the database call to be made, with neither helping.
Thank you in advance!