When I try to connect to a oracle in a docker container, from Oracle SQL Developer, I get the error "Got minus one from a read call, connect lapse 4 ms., Authentication lapse 0 ms."
I went on the oracle container page https://container-registry.oracle.com/ords/f?p=113:10::::::
I pulled express version, I was going to pull the standard but its been removed.
docker pull container-registry.oracle.com/database/express:latest
I then ran the image
docker run --name oracle-container -p 1521:5500 -e ORACLE_PWD=MyPasswd123 -e ORACLE_CHARACTERSET=AL32UTF8 -v /opt/oracle/oradata container-registry.oracle.com/database/express:latest
Got database started, and then logged in on the command line
docker exec -it oracle-container sqlplus sys/MyPasswd123@//localhost:1521/xe as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Sun Dec 11 10:49:14 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SQL>
Ran a command no problem
SQL> SELECT sys_context('userenv','instance_name') FROM dual;
SYS_CONTEXT('USERENV','INSTANCE_NAME')
--------------------------------------------------------------------------------
XE
The problem is trying to connect from java or from Oracle SQL Developer
I set username as sys as sysdba password as MyPasswd123@ HostName as localhost port as 1521 SID as XE
And I get the error. Its confusing as I can connect, using the command line docker exec -it
CodePudding user response:
You are binding enterprise manager (port 5500) to host port 1521.
# fire up the database
docker run --name oracle-container -d --rm -p 1521:5500 -e ORACLE_PWD=MyPasswd123 -e ORACLE_CHARACTERSET=AL32UTF8 container-registry.oracle.c
om/database/express:latest
# query from inside the container
echo 'select dummy from dual;' | docker container exec -i oracle-container sqlplus -S system/MyPasswd123@localhost:1521/XE
D
-
X
# query from outside the container
echo 'select dummy from dual;' | sqlplus -S system/MyPasswd123@localhost:1521/XE
ERROR:
ORA-12537: TNS:connection closed
# let's bind to the correct port
docker run --name oracle-container -d --rm -p 1521:1521 -e ORACLE_PWD=MyPasswd123 -e ORACLE_CHARACTERSET=AL32UTF8 container-registry.oracle.com/database/express:latest
# query from inside the container
echo 'select dummy from dual;' | docker container exec -i oracle-container sqlplus -S system/MyPasswd123@localhost:1521/XE
D
-
X
# query from outside the container. This time it works!
echo 'select dummy from dual;' | sqlplus -S system/MyPasswd123@localhost:1521/XE
D
-
X
Best of luck!