title: Mysql connection error in wso2 apim/identity server docker
body: <p>I have 3 dockerfiles for WSO2 apim, identity server, and mysql. using docker-compose to run these. The corresponding docker-compose.yml is given as below:-</p>
  
  <pre><code>    # docker-compose version
  version: "3.7"
  
  # services/containers to be run
  services:
    wso2am:
      build: ./apim
      image: wso2am:2.6.0
      ports:
        - "9443:9443"
      links:
        - mysql-db
        - wso2is-km
    wso2is-km:
      build: ./is-as-km
      image: wso2is-km:5.7.0
      ports:
        - "9444:9444"
      links:
        - mysql-db
    mysql-db:
      build: ./mysql
      image: mysql:5.7.26
      ports:
        - "3306:3306"
        - "33060:33060"
  </code></pre>
  
  <p>When running without changing h2 database to mysql Identity server/ apim works fine at ports 9444/9443 respectively. Also in mysql docker created regdb/apidb sql databases from the datascripts folder in apim/identity server.</p>
  
  <pre><code># Derived from official mysql image (our base image)
  FROM mysql:5.7
  MAINTAINER Abhilash K R &lt;abhilash.kr@aot-technologies.com&gt;
  
  ENV MYSQL_ROOT_PASSWORD root
  # Add a user
  ENV MYSQL_USER wso2carbon
  ENV MYSQL_PASSWORD wso2carbon
  
  # Add the content of the sql-scripts/ directory to your image
  # All scripts in docker-entrypoint-initdb.d/ are automatically
  COPY sql-scripts/ /docker-entrypoint-initdb.d
  # expose ports
  EXPOSE 3306 33060
  </code></pre>
  
  <p>Added jdbc driver and added new db url as below:</p>
  
  <pre><code>&lt;datasource&gt;
              &lt;name&gt;WSO2_CARBON_DB&lt;/name&gt;
              &lt;description&gt;The datasource used for registry and user manager&lt;/description&gt;
              &lt;jndiConfig&gt;
                  &lt;name&gt;jdbc/WSO2CarbonDB&lt;/name&gt;
              &lt;/jndiConfig&gt;
              &lt;definition type="RDBMS"&gt;
                  &lt;configuration&gt;
                      &lt;url&gt;jdbc:mysql://localhost:3306/regdb&lt;/url&gt;
                      &lt;username&gt;wso2carbon&lt;/username&gt;
                      &lt;password&gt;wso2carbon&lt;/password&gt;
                      &lt;driverClassName&gt;com.mysql.cj.jdbc.Driver&lt;/driverClassName&gt;
                      &lt;maxActive&gt;50&lt;/maxActive&gt;
                      &lt;maxWait&gt;60000&lt;/maxWait&gt;
                      &lt;testOnBorrow&gt;true&lt;/testOnBorrow&gt;
                      &lt;validationQuery&gt;SELECT 1&lt;/validationQuery&gt;
                      &lt;validationInterval&gt;30000&lt;/validationInterval&gt;
                      &lt;defaultAutoCommit&gt;true&lt;/defaultAutoCommit&gt;
                  &lt;/configuration&gt;
              &lt;/definition&gt;
          &lt;/datasource&gt;
  </code></pre>
  
  <p>Getting the error as below:
  <a href="https://i.stack.imgur.com/cZJ3a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cZJ3a.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/MiHKR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MiHKR.png" alt="enter image description here"></a>
  Thinking the error is at the url jdbc:mysql://localhost:3306/regdb , tried to give localhost/ip of the dockerhost also still didn0t work.</p>