title: using docker-compose unable to connect mysql and spring boot in same network
body: <p>Any help will be appreciated.
  I am trying to run mysql and spring-boot app in two container but, in same netowrk. 
  Using following command two container communicate each other. 
  <strong>mysql command</strong>
  <code>docker run --name mysql-local --network=spring-boot-network -p 4000:3306  -d -e MYSQL_ROOT_PASSWORD=password -e MYSQL_USER=root-user  -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=testdb mysql</code>
  <strong>application command</strong>
  <code>docker run --network=spring-boot-network -p 8080:8080 --name test-app -e RDH_HOSTNAME:mysql-local -e RDS_PORT:4000 -e RDS_USER:root-user -e -e RDS_PASSWORD:password 171ce195f461</code></p>
  
  <p>using above tow docker command two containers are created in <strong>spring-boot-network</strong> and they can communicate each other.
  problem arise when I tried to use docker-compose. 
  I passed same environments as command line but, my app refuse to connect with mysql.</p>
  
  <p>I am using spotify plugin to create an image. </p>
  
  <pre><code>&lt;plugin&gt;
                  &lt;groupId&gt;com.spotify&lt;/groupId&gt;
                  &lt;artifactId&gt;dockerfile-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.4.3&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;default&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;build&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;repository&gt;rajesh132/test-docker&lt;/repository&gt;
                      &lt;tag&gt;${project.version}&lt;/tag&gt;
                      &lt;buildArgs&gt;
                          &lt;JAR_FILE&gt;${project.build.finalName}.jar&lt;/JAR_FILE&gt;
                      &lt;/buildArgs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>when I startup container mysql container is created and started. I can connect to it using mysqlsh client and mysql workbench as well. However, I cannot connect to my application. Following are properties and docker files that I used in my project. 
  <strong>Docker file</strong></p>
  
  <pre><code>ADD target/docker-test.jar docker-test.jar
  ENTRYPOINT ["java", "-jar", "docker-test.jar"]
  </code></pre>
  
  <p><strong>Docker Compose file</strong></p>
  
  <pre><code>version: '3.7'
  services:
    spirng-boot-test-application:
      image: rajesh132/test-docker:0.0.1-SNAPSHOT
        #build:
        #context: .
      #dockerfile: Dockerfile
      ports:
        - "8080:8080"
      restart: always
      depends_on: # Start the depends_on first
        - mysql-app
      environment:
        RDS_HOSTNAME: mysql-app
        RDS_PORT: 4000
        RDS_DB_NAME: testdb
        RDS_USERNAME: test-user
        RDS_PASSWORD: password
      networks:
        - web-application-network
  
    mysql-app:
      image: mysql
      ports:
        - "4000:3306"
      restart: always
      environment:
  
        MYSQL_ROOT_PASSWORD: password
        MYSQL_USER: test-user
        MYSQL_PASSWORD: password
        MYSQL_DATABASE: testdb
      volumes:
        - mysql-database-data-volume:/var/lib/mysql
      networks:
        - web-application-network
  
  # Volumes
  volumes:
    mysql-database-data-volume:
  
  networks:
    web-application-network:
  </code></pre>
  
  <p><strong>application.yml</strong></p>
  
  <pre><code>  datasource:
      #  use this url for localhost
      #use docker container name instead 'localhost'
      #  url: jdbc:mysql://localhost:3306/authorizationDb?createDatabaseIfNotExist=true
      url: jdbc:mysql://${RDS_HOSTNAME:localhost}:${RDS_PORT:3306}/${RDS_DB_NAME:test}?createDatabaseIfNotExist=true&amp;useSSL=false&amp;allowPublicKeyRetrieval=true
      username: ${RDS_USER:root}
      password: ${RDS_PASSWORD:password}
      driver-class-name: com.mysql.cj.jdbc.Driver
      initialization-mode: always
      tomcat:
        test-on-borrow: true
        validation-query: SELECT 1
    jpa:
      hibernate:
        naming:
          physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
        ddl-auto: update
      properties:
        hibernate:
          show_sql: true
          format_sql: true
      database-platform: org.hibernate.dialect.MySQL8Dialect
  
  logging:
    level:
      org:
        hibernate:
          type: trace
  </code></pre>
  
  <p>I followed so many blogs, documentation, however coundnt succeed to build. Any help much appreciate. </p>