Can’t connect to Oracle 12c Release 1 in docker container from host

dockeroracleoracle-12c

I pulled the Oracle 12.1.0.2 docker image from the Oracle Container Registry (container-registry.oracle.com/database/standard:12.1.0.2) and created a container as per the instructions, leaving the environment file blank so as to keep all the parameters as their defaults (I am aware that I should change the password etc but right now I just want to get it working).

$ docker run -d --env-file ./db_env.dat -p 1527:1521 -p 5507:5500 -it --name dockerDB --shm-size="8g" container-registry.oracle.com/database/standard

I was able to successfully start the container, and can access it via docker exec. I was also able to verify that the Oracle instance was running correctly by executing some sqlplus against it from the shell inside the container.

However, I am not able to connect to the Oracle instance from my host machine, either through SQL Developer:

Developer hanging connection

or through sqlplus:

SQL*Plus hanging connection

I get no errors, but the connection process just hangs forever. Do I need to change some setup somewhere or have I got the details wrong?

Best Answer

I'm running Oracle 11g Personal edition docker container

$ docker ps
CONTAINER ID        IMAGE                                    COMMAND                  CREATED             STATUS              PORTS                                                                     NAMES
d84af138d77a        oracleinanutshell/oracle-xe-11g:latest   "/bin/sh -c '/usr/sb…"   22 minutes ago      Up 22 minutes       0.0.0.0:32777->22/tcp, 0.0.0.0:32776->1521/tcp, 0.0.0.0:32775->8080/tcp   oracle-xe-11g

As you can see port 1521 was mapped to 32776.

Replace 0.0.0.0 with ipaddress of docker vm running on Virtualbox i.e 192.168.99.100

 sqlplus test/test@192.168.99.100:32776/XE

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 9 13:12:19 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

If you're trying to login as sys user add sysdba at the end