I trying to connect a web server that runs in an Apache Tomcat container to a MySQL database that runs another container. In order to do that I am using the linking mechanism from Docker.
docker run -it --name ${CONTAINER_NAME} --link db:db -p 8080:8080 -d tomcat
After running the container I can see that the containers are linked and the environment variables are exposed properly.
In order to connect the web application that is running in the Tomcat container to the database, I am using the following configuration file:
<Context>
<Resource
name="jdbc/MYDB"
type="javax.sql.DataSource"
auth="Container"
username="user"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://${DB_PORT_3306_TCP_ADDR}:${DB_PORT_3306_TCP_PORT}/epcis?autoReconnect=true">
</Resource>
</Context>
Now the problem is that I can't establish the connection to the database because the environment variables exposed by Docker are not recognized at the Tomcat environment.
There is a way to make these environment variables exposed by Docker visible to the Apache Tomcat environment?