Search code examples
databaseoracledockersqlplusunified-log

How to use sqlplus on Oracle database inside a docker container?


I installed oracle db version 12c in my docker environment. I used the following command:

docker run -d --name oracle -p 8080:8080 -p 1521:1521 quay.io/maksymbilenko/oracle-12c

I connected to the DB and everything went well but I wanted to enable unified audit. In order to do that, at first you must shutdown the Database and in all the instructions that I found it says to use sqlplus as following:

sqlplus / as sysoper
SQL> shutdown immediate
SQL> exit

I connected successfully to the DB using the next command:

docker exec -it oracle "bash"

and then I ran the sqlplus command and I received "command not found"

[root@f30cc670f85f /]#   sqlplus / as sysoper
bash: sqlplus: command not found

Am I doing it wrong? What should I do in order to have sqlplus on my oracle DB? I looked for it and didn't find anything that helped me.

I have mac if its relevant


Solution

  • I think that Docker image is just the database and enough of the OS to run the database. I don't think it includes client software such as SQL*Plus.

    You need to have SQL*Plus installed on your Mac. If you haven't already, download the Oracle Instant Client for MacOS including the SQL*Plus extension. Or why not treat yourself and install the new-fangled sqlCL tool? It is easier to install and has all the SQL*Plus capabilities and a whole bunch more features. Find it here.

    Whatever client you choose, once it's installed on your Mac you run it like any other app: when prompted for connection you give the string Maksym provides:

    sqlplus user/password@ip:port/service-name
    sqlplus system/oracle@//localhost:1521/xe 
    

    If you need to connect as sys that would look like this:

    sqlplus sys/oracle@//localhost:1521/xe as sysdba