Why is OracleDB locking up in Docker

-setupdockeroracleoracle-12c

I am trying to set up an Oracle database in Docker, and once the database is up and running, I can exec into sqlplus just fine, but if I try to connect with another application like Oracle SQL Developer or SQuirreL, either it will stall out while trying to connect, or it will manage to connect and then all future queries will stall. What is wrong with this?

Here is how I set up the container:
I used the docker image available from Oracle on Docker Hub.

Here is the command I ran to create the container:

docker run --name someName -p 1521:1521 -p 5500:5500 -e ORACLE_SID=SOMESID -e ORACLE_PDB=SOMEPDBNAME -e ORACLE_PWD=12345 -it 12a359cd0528

Here are the commands I ran once the container was up and running:

docker exec -it npsIG /bin/bash
sqlplus / as sysdba
alter session set "_ORACLE_SCRIPT"=true;
create user username identified by 12345;
grant dba to username;

At this point, sometimes I can connect on the created user, sometimes it just stalls out. If I manage to connect on the created user, no further queries will process.

Best Answer

IF that is actually your script, then after you connect "/ as sysdba", then sqlplus is simply waiting for input. It doesn't see the 'alter session', etc, because those aren't being redirected into sqlplus. Rather, they are simply treated as the next command for the shell to process after sqlplus exits.

Try this:

sqlplus / as sysdba <<EOF 
alter session set "_ORACLE_SCRIPT"=true;
create user username identified by 12345; 
grant dba to username; exit
EOF

BTW, you should not be using 'as sysdba' if you can accomplish the same thing with a less privileged user, such as SYSTEM. Connecting to oracle as SYS is like connecting to Linux as root. You are running with scissors, knives, and blowtorches, all without a net.