title: Docker Compose - Flyway - Unable to obtain Jdbc connection from DataSource
body: <p>I'm traying to deploy a microserivice and a flyway service with Docker Compose in Ubuntu. The docker-compose.yml looks like this:</p>
  
  <pre><code>version: '2'
  
  services:
  
  mysqldb:
  image: mysql:5.6.26
  environment:
    MYSQL_USER: user
    MYSQL_PASSWORD: password
    MYSQL_ROOT_PASSWORD: password
    MYSQL_DATABASE: base
  ports:
    - "3306:3306"
  
  flyway-service-i:
  image: mialk/flyway-service
  volumes:
   - "../resources/db/migration:/migrations/ro"
  depends_on:
   - mysqldb
  links:
   - mysqldb
  command: migrate -url=jdbc:mysql://mysqldb:3306/base -user=user -password=password -baselineOnMigrate=true -    locations='filesystem:/migrations'
  
    service1:
  image: my/service
  ports:
    - "8080:8080"
  links:
   - mysqldb
  environment:
    - SPRING_DATASOURCE_URL=jdbc:mysql://mysqldb:3306/base
    - SPRING_DATASOURCE_USERNAME=user
    - SPRING_DATASOURCE_PASSWORD=password
  </code></pre>
  
  <p>But when I run the command: sudo docker-compose up, I have this message:</p>
  
  <p><strong>flyway-service-i_1  | ERROR: Unable to obtain Jdbc connection from DataSource (jdbc:mysql://mysqldb:3306/base) for user 'user': Host <em>'172.18.0.4'</em> is not allowed to connect to this MySQL server</strong></p>
  
  <p>Each time that I run the command, I get a different host, e.g:</p>
  
  <p><strong>ERROR: Unable to obtain Jdbc connection from DataSource (jdbc:mysql://mysqldb:3306/base) for user 'user': Host <em>'172.18.0.6'</em> is not allowed to connect to this MySQL server</strong></p>
  
  <p>The data base was created in that way:</p>
  
  <pre><code>CREATE DATABASE base CHARACTER SET utf8 COLLATE utf8_bin;
  GRANT ALL PRIVILEGES ON base.* To 'user'@'localhost';
  </code></pre>
  
  <p>The ifconfig command shows that Docker has the IP 172.17.0.1.</p>
  
  <p>I don't know why flyway can't connect to the data base, and why the host changes en each call,can you help me please?</p>
  
  <p><strong>Thanks! :)</strong> </p>