title: Communications link failure in Spring Boot app using MySQL from Docker
body: <p>My Spring Boot application uses MySQL database tables, which it creates upon application startup using liquibase config files. All runs great when I run the app locally (I have MySQL running locally).</p>
  <p>I want to deploy the app to a single container in Docker.</p>
  <p>The docker build creates the image successfully, but when I start up the container, I get:</p>
  <pre><code>Error starting ApplicationContext. 
  ...
  Caused by: liquibase.exception.DatabaseException: 
  com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
  </code></pre>
  <p>I have these spring boot variables in my <code>application.properties</code> in my Spring app:</p>
  <pre><code>spring.datasource.url=jdbc:mysql://localhost:3306/mydb
  spring.datasource.username=root
  spring.datasource.password=password
  </code></pre>
  <p>Those variables work without issue when I run my app locally. But when I run from a docker container I get that <em>Communications link failure</em>.</p>
  <p>I'm thinking the issue might be that the container is isolated from my local MySQL jdbc url. Is there any way around that? I.e., is there a way to configure the container to use my local MySQL?</p>
  <p>In <a href="https://stackoverflow.com/a/58881813/3368818">this</a> similar issue, the problem is from having <code>localhost</code> in the jdbc url. But that example takes a different approach than mine in that they're using a separate <code>docker-mysql</code> image. In my case, I just want one container, which includes the app and the database together. Is this possible?</p>