Docker Community Forums

Share and learn in the Docker community.

Spring boot app running inside docker container unable to connect to Oracle DB on network

(Rhanda) #1

I am new to docker, I am trying to run spring boot app (microservice) in docker container, app is trying to access a oracle db on network not running inside docker container

public DataSource oracleDataSource() throws SQLException {
            final SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
            dataSource.setDriver(new OracleDriver());

            return dataSource;

It works fine when same code is run from eclipse but when running inside docker container it throws kdb-us-engdba11: unknown error. I tried

docker run" 
and  "docker run --net=host .....

both option does not seems like helping, how to access network resource from docker container. I am running the code on mac with Boot2Docker for OSX.

Thanks, Rahul

(Ranjandas) #2

Hi Rahul,

You have used fqdn for --add-host where as your code is using a short name. Possibly this is the problem. You have two options here.

  • Either run the container using short name
    docker run --add-host=kdb-us-engdba11:10.48.15 1.183 ....

  • Or edit the code and use fqdn in the connection url dataSource.setUrl.