1 Reply Latest reply on May 23, 2016 3:52 AM by xcoulon

    Wildfly container can't recognize the mariadb container host name in docker tooling

    aupres

      My os is CentOS 7 and I am using Eclipse JBossTools plugin including Docker Tooling. I have 2 running container where one is wildfly 10 and the other is mariadb.

      Both are working successfully but link of both container is failed. When connection request from wildfly is sent, connection is refused. It throws the following exception,

       

      ERROR [stderr] (default task-1) Caused by: java.net.UnknownHostException: dockerhost: unknown error

       

      However , in database development perspective of eclipse ide, the following jdbc url to mariadb container is working,

       

      jdbc:mysql://dockerhost:3306/test?useUnicode=true&characterEncoding=utf8

       

      My host name is dockerhost.
      I have no idea what is the the problem.
      Your advice will be deeply appreciated! Thanks for reading

        • 1. Re: Wildfly container can't recognize the mariadb container host name in docker tooling
          xcoulon

          Hello Joseph,

           

          To let WildFly access the MariaDB database, you should use the environment variables that Docker will add into the WildFly container when it is linked to the MariaDB container (on the second page of the 'Run Image' wizard in the Docker tooling.

          These environment variables should have the following form:

           

          To find the exact name (and values), you can run the following command from CLI:

           

          docker exec -it <wildfly_container_name> /bin/bash

           

          where <wildfly_container_name> is the name of the WildFly container that you specified or that Docker did set at creation.

           

          then, once you have the ssh session in the container:

           

          env | grep <mariadb_alias_name>

           

          where <mariadb_alias_name> is the alias of the MarisDB container that you specified when linking it to the WildFly container.

           

          You can also run the same '/bin/bash' commands in the Terminal view of Eclipse using the Docker Tooling 2.0.0.RC1 (released last week). You'll need to open the Docker Containers view to get the context menu. It should be available in the Docker Explorer in the next release.

           

          I used a similar exemple with PostgreSQL in a couple of demos and I used the following datasource definition:

           

          <datasource jndi-name="java:jboss/datasources/PostgreSQLDS" use-java-context="true" pool-name="PostgreSQLDS">

            <connection-url>jdbc:postgresql://${env.POSTGRES_PORT_5432_TCP_ADDR}:${env.POSTGRES_PORT_5432_TCP_PORT}/postgres</connection-url>

            <driver>postgresql</driver>

            <security>

              <user-name>${env.POSTGRES_ENV_POSTGRES_USERNAME}</user-name>

              <password>${env.POSTGRES_ENV_POSTGRES_PASSWORD}</password>

            </security>

            <validation>

              <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>

              <background-validation>true</background-validation>

            </validation>

            <pool>

              <flush-strategy>IdleConnections</flush-strategy>

            </pool>

          </datasource>

           

          In particular, see the ${env.POSTGRES_xxx} variables (in my case, "POSTGRES" was the alias that I used)

           

          Best regards,

          Xavier