title: Connecting Spring boot application to Oracle database 12.2.0.1 in Docker container
body: <p>I have Oracle database running as Docker container and following are the container details.</p>
  
  <pre><code>Config: {
          "Hostname": "8ad016675bd2",
          "Domainname": "",
          "User": "oracle",
          "AttachStdin": true,
          "AttachStdout": true,
          "AttachStderr": true,
          "ExposedPorts": {
              "1521/tcp": {},
              "5500/tcp": {}
          },
          "Tty": true,
          "OpenStdin": true,
          "StdinOnce": true,
          "Env": [
              "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
              "ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1",
              "ORACLE_SID=ORCL"
          ],
          "Cmd": [
              "/bin/sh",
              "-c",
              "/bin/bash /home/oracle/setup/dockerInit.sh"
          ],
          "Healthcheck": {
              "Test": [
                  "CMD-SHELL",
                  "/bin/bash /home/oracle/setup/healthcheck.sh"
              ],
              "Interval": 60000000000,
              "Timeout": 10000000000
          }
      },
      "NetworkSettings": {
          "Bridge": "",
          "SandboxID": "c13a0ee218e9245d7916c7ffb078adf4191a14e100221274f3125975fc6cb5b7",
          "HairpinMode": false,
          "LinkLocalIPv6Address": "",
          "LinkLocalIPv6PrefixLen": 0,
          "Ports": {
              "1521/tcp": [
                  {
                      "HostIp": "0.0.0.0",
                      "HostPort": "32773"
                  }
              ],
              "5500/tcp": [
                  {
                      "HostIp": "0.0.0.0",
                      "HostPort": "32772"
                  }
              ]
          },
          "SandboxKey": "/var/run/docker/netns/c13a0ee218e9",
          "SecondaryIPAddresses": null,
          "SecondaryIPv6Addresses": null,
          "EndpointID": "782fa0c989db7f58643416fea7b60165ad00ce3067b7bb7a6af72c0619c31e5a",
          "Gateway": "172.17.0.1",
          "GlobalIPv6Address": "",
          "GlobalIPv6PrefixLen": 0,
          "IPAddress": "172.17.0.2",
          "IPPrefixLen": 16,
          "IPv6Gateway": "",
          "MacAddress": "02:42:ac:11:00:02",
          "Networks": {
              "bridge": {
                  "IPAMConfig": null,
                  "Links": null,
                  "Aliases": null,
                  "NetworkID": "486e58b051b36eb20838e5f9edcb6fe205407e583e75fedf86460ecec41dd9c5",
                  "EndpointID": "782fa0c989db7f58643416fea7b60165ad00ce3067b7bb7a6af72c0619c31e5a",
                  "Gateway": "172.17.0.1",
                  "IPAddress": "172.17.0.2",
                  "IPPrefixLen": 16,
                  "IPv6Gateway": "",
                  "GlobalIPv6Address": "",
                  "GlobalIPv6PrefixLen": 0,
                  "MacAddress": "02:42:ac:11:00:02",
                  "DriverOpts": null
              }
          }
  </code></pre>
  
  <p>I am trying to connect to the oracle database with Flyway using below credentials</p>
  
  <pre><code>spring.jpa.database=oracle
  spring.datasource.url=jdbc:oracle:thin:@172.17.0.2:32773/ORCLPDB1
  spring.datasource.username=sys
  spring.datasource.password=Oradoc_db1
  </code></pre>
  
  <p>But I am getting following error</p>
  
  <pre><code>Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
  at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:523) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:521) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:660) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.net.ns.NSProtocol.connect(NSProtocol.java:286) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1438) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:518) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  ... 35 common frames omitted
  Caused by: java.io.IOException: Connection timed out: connect, socket connect lapse 21030 ms. /172.17.0.2 32773 30000 1 true
  at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:209) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.net.nt.ConnOption.connect(ConnOption.java:161) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:470) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  ... 40 common frames omitted
  
  Unable to obtain connection from database: IO Error: The Network Adapter 
  could not establish the connection
  ---------------------------------------------------------------------------- 
  -------------------------------
  SQL State  : 08006
  Error Code : 17002
  Message    : IO Error: The Network Adapter could not establish the 
  connection
  </code></pre>
  
  <p>Can anybody point out what I am missing here? And how to fix this.</p>