Reputation: 101
I'm running on the same host a tomcat container where I've deployed a web application and an oracle DB container. The settings I'm using the following settings to connect from the web app to the oracle DB container:
spring.datasource.url: jdbc:oracle:thin:@<IP of the host>:1521:xe
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverClassName=com.mysql.jdbc.Driver
As I'm exposing the port 1521 to the host, I was expecting to be able to connect to the Oracle DB with no issues, furthermore, I can connect from my laptop to the Oracle DB using DbVisualizer using the settings described above. I've also got into the tomcat container and pinged the host with success.
I know I could link both containers when running the "docker run" command but I was wondering if it could work this way too.
Any ideas? Thanks!
Upvotes: 0
Views: 936
Reputation: 1705
A simple way to do this is using docker-compose:
docker-compose.yml
version:'3'
services:
app:
// if you got a custom dockerfile
build: .
links:
- db
db:
image: oracledb
The db host into app will "db":
spring.datasource.url: jdbc:oracle:thin:db:1521:xe
To run bought contanier at the same time is: docker-compose up --build
I hope you find it useful.
Upvotes: 1