简体   繁体   中英

Docker external database mapping

I have cloned 'knowage' BI tool to my local cetnos 7 server and successfully ran the docker containers. My challenge is in connecting to a mariadb database that is in the Host machine! I want the knowage container to access that database in the Host machine. below is my server.xml file for the connection configs used by knowage..

<GlobalNamingResources>

<Resource name="jdbc/datasource" auth="Container"
      type="javax.sql.DataSource"
      driverClassName="org.mariadb.jdbc.Driver"
      url="jdbc:mariadb://ip-addr:3306/datasource"
      username="beberu"
      password="***********"
      maxActive="20" maxIdle="10"
      maxWait="-1"/>

            <!-- KNOWAGE -->
<Resource auth="Container" driverClassName="org.mariadb.jdbc.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/knowage" type="javax.sql.DataSource" url="jdbc:mysql://1$

<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="$

<ResourceLink global="jdbc/datasource" name="jdbc/datasource" type="javax.sql.DataSource"/>
</GlobalNamingResources>

You have to use the ip address of the docker0 interface in the place of 10.66.110.7.

You can get the ip address using this command.

$ ip addr show docker0

In the result use the ip after, inet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM