0

I have a server running Oracle 19c inside a Docker container, and I would like the ability to log into the database from the host using sqlplus.

Inside the container, I am able to run this command successfully:

sqlplus john/[email protected]:1521/XYZ

However, when ran from outside the container, the command hangs for ~60 seconds then fails and returns this error:

ORA-12637: Packet receive failed

How can I log into the database from the host?

docker-compose.yml:

version: '3.8'
name: db
services:
  database:
    image: doctorkirk/oracle-19c:19.3
    volumes:
      - ~/oracle19c/data/:/opt/oracle/oradata
    ports:
      - 1521:1521
    environment:
      - ORACLE_SID=XYZ
      - ORACLE_PWD=oracle

docker ps:

user@test-db:~$ docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS                    PORTS                                       NAMES
29ba3a2ebe95   doctorkirk/oracle-19c:19.3   "/bin/sh -c 'exec $O…"   16 minutes ago   Up 15 minutes (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp   db-database-1

listener.ora:

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

DEDICATED_THROUGH_BROKER_LISTENER=ON
DIAG_ADR_ENABLED = off

netstat -tulpn from inside the container:

[oracle@29ba3a2ebe95 ~]$ netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:1521            0.0.0.0:*               LISTEN      17/tnslsnr
tcp        0      0 127.0.0.11:34963        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:34633           0.0.0.0:*               LISTEN      88/ora_d000_XYZ
udp        0      0 127.0.0.11:37794        0.0.0.0:*                           -
udp        0      0 127.0.0.1:54395         0.0.0.0:*                           90/ora_s000_XYZ
udp        0      0 127.0.0.1:38515         0.0.0.0:*                           88/ora_d000_XYZ
udp        0      0 127.0.0.1:52421         0.0.0.0:*                           76/ora_lreg_XYZ

netstat -tulpn from the host:

user@test-db:~$ netstat -tulpn
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:1521            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::80                   :::*                    LISTEN      -
tcp6       0      0 :::1521                 :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
3
  • Is the host firewall blocking the connection?
    – pmdba
    Mar 23, 2023 at 21:16
  • @pmdba This is minimal Debian install, no firewall by default. Just double-checked iptables. Also Docker is binding the port to localhost which most firewalls don't touch. Running nmap 127.0.0.1 -p 1521 -sV shows Nmap recognizes the port is running Oracle 19c. Mar 23, 2023 at 22:58
  • Additionally, bringing the Docker container down followed by running the same login command immediately (no 60 sec hang) returns a different error: ORA-12541: TNS:no listener Mar 23, 2023 at 23:03

1 Answer 1

0

This was fixed by pointing SQLPlus to the database container's Docker subnet IP instead of localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.