nifu
nifu

Reputation: 57

Connect to Oracle XE Docker container

I have problems reaching an Oracle XE database Docker container (Version 2.3.0.4) via Telnet or SQLPLUS from my hostsystem:

This is my Oracle XE and Container configuration:

docker port 54cb9336d8c3
1521/tcp -> 127.0.0.1:1521

Oracle configuration:

cat /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
DEFAULT_SERVICE_LISTENER = XE

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

cat /opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora
XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

LISTENER_XE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))

lsnrctl output:

lsnrctl status

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 05-SEP-2020 13:29:49

Copyright (c) 1991, 2018, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date                04-SEP-2020 23:23:29
Uptime                    0 days 14 hr. 6 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/54cb9336d8c3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=127.0.0.1)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/XE/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "XE" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
Service "ae7e9c04366c09a3e053030011ac556e" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
Service "xepdb1" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully

I can access via SQLPLUS from the Docker Container to the XE database, but it is not possible to connect to the DB from my hostsystem.

Telnet to Port 1521 (in Docker container)

[root@54cb9336d8c3 admin]# telnet localhost 1521
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Telnet to Port 1521 (from macOS Host)

telnet localhost 1521
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

Did I miss anything in the configuration of the Oracle DB or the Docker Container?

Upvotes: 0

Views: 4483

Answers (1)

Konrad Botor
Konrad Botor

Reputation: 5063

It's been a while since I've configured Oracle DB, but it seems to me you have your listener set up to only listen on the loopback interface.

You should try this configuration instead:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

For comparison, here's listener.ora from official Oracle Database Enterprise Edition Docker image:

LISTENER =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))     )   ) 
DIAG_ADR_ENABLED = off
SSL_VERSION = 1.0

and tnsnames.ora from the same image:

ORCLCDB =   (DESCRIPTION =     (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))     (CONNECT_DATA =       (SERVER = DEDICATED)       (SERVICE_NAME = ORCLCDB.localdomain)     )   ) 
ORCLPDB1 =   (DESCRIPTION =     (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))     (CONNECT_DATA =       (SERVER = DEDICATED)       (SERVICE_NAME = ORCLPDB1.localdomain)     )   )

Upvotes: 1

Related Questions