How to install OracleDB on Docker

I come up with this problem yesterday, Oracle is potentiating their cloud solutions so they are not making it that easy to install their star product on a testing environment. Even though I manage to do it and this is how I did it!

Contents

Installing Docker

First of all, we will need Docker installed and you need to register to Docker hub.

Here you have a little manual on How to install Docker. About the docker hub, you must register in Docker webpage, here you have the link (You can also do this in Docker).

Downloading OracleDB image

OracleDB doesn’t have anymore an official image in the Hub, but I found this one. There are also independent images on GitHub, but in this case, we will use this one. First of all, we are going to download it. Make sure you have your docker installation on, now open a command line and write this code (Make sure you are sign on your Docker application before trying this):

docker pull oracledb19c/oracle.19.3.0-ee:oracle19.3.0-ee

Running the image in a Docker Container

Well done! Now we have the image downloaded.

Let’s run the container.

docker run --name oracle19c -p 1521:1521 -p 5500:5500 -v /opt/oracle/oradata -d oracledb19c/oracle.19.3.0-ee:oracle19.3.0-ee

This will give us the next output:

ORACLE EDITION: ENTERPRISE
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: BkQhFH1AtbY=1

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 17-OCT-2022 03:06:11

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

Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/4916e98e1c0d/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                17-OCT-2022 03:06:11
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/4916e98e1c0d/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

As you may see, in the second line it will give us the password from the SYS user. Now we should wait for the DB to complete its setup and in the last lines, it will give us our database name (Typically ORCLCDB).

Connecting to our OracleDB instance

Now we can connect to the instance using this command:

docker exec -u 0 -it oracle19c /bin/bash
bash-4.2# ls
setPassword.sh

The oracle image comes with a setPassword.sh that let you change the default password to do it, run this command inside the instance:

./setPassword.sh [YOUR_NEW_PASSWORD]

To connect to the SQL database, you can run this command:

sqlplus /nolog
SQL> connect SYS@ORCLCDB AS SYSDBA
Enter password:
Connected.

Connecting with SQL developer

Oracle has a program called SQL developer that you can also use to connect to your instance. You can download it on this link.

Install it and then click on Oracle Connections > New connection

Now we should configure it the next way:

User: SYS AS SYSDBA

Password: Your_Password

Service Name: ORCLCDB

Conclusion

It is not that complicated to install and get running OracleDB in a Docker container, but it still has some difficulties.

Now you can create your OracleDB testing environment!

Leave a Reply