-
1. Re: Wildfly container can't recognize the mariadb container host name in docker tooling
xcoulon May 23, 2016 3:52 AM (in response to aupres)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