title: Configure app and MySQL DB in docker-compose.yaml - Could not open JDBC Connection
body: <p>I configured an app and mysql db within a docker-compose.yaml file below. While both services start, the app cannot open a connection to the DB when an http request is sent. When the app and mysql DB are defined in separate containers, the request succeeds. I am sure it is something simple in the docker compose config.</p>
  
  <pre><code>version: '3.7'
  
  services:
    database:
      image: mysql:5.7
      container_name: docker_test-device-telemetry-mysql
      command: --explicit_defaults_for_timestamp
      environment:
        MYSQL_ROOT_PASSWORD: 12345
        MYSQL_ALLOW_EMPTY_PASSWORD: "no"
  
      volumes:
      - ./initdb.d:/docker-entrypoint-initdb.d
      ports:
      - "6603:3306"
  
    device-telemetry:
      image: 224713337986.dkr.ecr.eu-west-1.amazonaws.com/device-telemetry:2.5.0
      container_name: docker_test-device-telemetry-app
      volumes:
        - ./application.yaml:/application.yaml
        - ./bootstrap.yaml:/bootstrap.yaml
      ports:
        - "7857:7847"
      depends_on:
        - database
  </code></pre>
  
  <p>"timestamp": "2018-10-18T20:46:17.654+0000",
    "status": 500,
    "error": "Internal Server Error",
    "exception": "org.springframework.transaction.CannotCreateTransactionException",
    "message": "<strong>Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory</strong> (Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)",
  }</p>