Reputation: 6358
Mac OS and docker From the oracledb console, I can not connect as sys, password I type in oracle and no go
SQL> connect sys as sysdba;
Enter password:
ERROR:
ORA-12547: TNS:lost contact
how did I get this far...
docker pull absolutapps/oracle-12c-ee
docker run -d --name oracle-12cR1-ee --privileged absolutapps/oracle-12c-ee
docker logs -f oracle-12cR1-ee
at then end of that I get
PL/SQL procedure successfully completed.
Please login to http://<ip_address>:8080/em to use enterprise manager
User: sys; Password oracle; Sysdba: true
Fixing permissions...
Running init scripts...
Init scripts in /oracle.init.d/: Ignoring /oracle.init.d/*
Done with scripts we are ready to go
Next command I run is
docker exec -it 28b0f34f7a81 bash -c "source /home/oracle/.bashrc; sqlplus /nolog"
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 28 23:08:41 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> connect sys as sysdba;
Enter password:
ERROR:
ORA-12547: TNS:lost contact
at this point, I am stuck...
Thoughts or seen this before?
Upvotes: 1
Views: 3187
Reputation: 644
Looking at the source code for that image you're using I was able to see that they're using gosu oracle sqlplus
to connect to the database with elevated privileges, so I tried this in my environment and seems to fit perfectly to what you need:
docker exec -it oracle-12cR1-ee sh -c 'gosu oracle sqlplus "sys as sysdba"'
getting..
SQL*Plus: Release 12.1.0.2.0 Production on Sat Jun 29 00:33:12 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
and then being able to (for example):
SQL> SELECT USERNAME from SYS.ALL_USERS;
Enjoy! ;)
Edit:
Using just sqlplus / as sysdba
also works as well, so it would be:
docker exec -it oracle-12cR1-ee sh -c 'gosu oracle sqlplus / as sysdba'
Upvotes: 4