title: Cant access oracle db with my Java spring boot Docker image because of the error: oracle.net.ns.NetException: Unknown host specified
body: <p>I can not connect oracle db in Docker image whereas I can connect to it via IntelliJ. The project is a spring boot maven project. Here is regarding part of my application.yml file:</p>
  <pre><code>    datasource:
        url: jdbc:oracle:thin:@host_name:port/service_name
        username: username
        password: password
        driver-class-name: oracle.jdbc.driver.OracleDriver
  
    jpa:
      hibernate:
        ddl-auto: update
        show-sql: true
        format_sql: true
        dialect: org.hibernate.dialect.Oracle10gDialect
  </code></pre>
  <p>With this configuration I can connect to the oracle using <strong>ojdbc6.ja</strong>r. However when I try to run project with docker-compose with the same configuration I can not connect to db. It gives <strong>oracle.net.ns.NetException: Unknown host specified</strong> error. This is my docker-compose:</p>
  <pre><code>database:
      container_name: db
      image: db
      build: ./
      ports:
        - &quot;8091:8091&quot;
      environment:
        - SPRING_DATASOURCE_URL=jdbc:oracle:thin:@host_name:port/service_name
        - SPRING_DATASOURCE_USERNAME=username
        - SPRING_DATASOURCE_PASSWORD=password
        - SPRING_DATASOURCE_DRIVER_CLASS_NAME=oracle.jdbc.driver.OracleDriver
        - SPRING_JPA_HIBERNATE_DDL_AUTO=update
        - SPRING_JPA_HIBERNATE_DIALECT=org.hibernate.dialect.Oracle10gDialect
      networks:
        - my_network1
  </code></pre>
  <p>Is it related that I am using host_name instead of IP? I do not know the IP address of the db server. If that is the problem I would be glad if you tell me any way to get IP from host name if it is possible.</p>
  <p>Why docker-compose can not connect the oracle db? I am new with Docker. Is there anything I am missing? Thanks for any help.</p>