Installing Oracle Database on macOS using Oracle Docker Images

Technology is constantly evolving, and with it, the methods of installation have changed. For DBAs who once relied on CDs or diskettes to install Oracle databases, the ability to quickly and easily create and deploy a database using Docker images provided by Oracle is truly impressive. In this post, I will cover the deployment of Oracle database 18.4 using the free and simplified edition, Oracle Express, on MacOS Monterrey 12.6.5. To begin, I would like to share the necessary tools that one must download in order to achieve this goal. The list of required tools is as follows:

SQL Plus Instant Client: https://www.oracle.com/se/database/technologies/instant-client/macos-intel-x86-downloads.html

Basic Package (ZIP) and SQL*Plus Package (ZIP)

After downloading these files, please move them to a directory created under the user’s home and unzip it:


base) brunotechdatabasket@Brunos-MBP oracle % ls -ltr
total 166056
-rw-r--r--@ 1 brunotechdatabasket  staff  75201214 May 18 20:02 instantclient-basic-macos.x64-19.8.0.0.0dbru.zip
-rw-r--r--@ 1 brunotechdatabasket  staff    935200 May 18 20:02 instantclient-sqlplus-macos.x64-19.8.0.0.0dbru.zip
(base) brunotechdatabasket@Brunos-MBP oracle % unzip -d ~/bin/oracle 

Testing the SQLPLUS utility:


(base) brunotechdatabasket@Brunos-MBP instantclient_19_8 % export  D_LIBRARY_PATH=$HOME/bin/oracle/instantclient_19_8:$LD_LIBRARY_PATH
(base) brunotechdatabasket@Brunos-MBP instantclient_19_8 % export PATH=$LD_LIBRARY_PATH:$PATH
(base) brunotechdatabasket@Brunos-MBP instantclient_19_8 % sqlplus -V

SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.8.0.0.0


Now that both the client and the SQL*Plus utility are in place, the next step is to clone the Docker image from Oracle’s GitHub repository, as shown below:

Oracle’s Github link: https://github.com/oracle/docker-images

Oracle Database Enterprise Edition Installation Guide for Docker Containers For Oracle Linux x86-64: https://docs.oracle.com/en/database/oracle/oracle-database/21/deeck/index.html#DEEDK-GUID-EDA557B2-B0D6-45E1-8FBD-C1D756803982


(base) brunotechdatabasket@Brunos-MBP instantclient_19_8 % mkdir ~/oracle
(base) brunotechdatabasket@Brunos-MBP instantclient_19_8 % git clone https://github.com/oracle/docker-images.git ~/oracle
Cloning into '/Users/brunotechdatabasket/oracle'...
remote: Enumerating objects: 16905, done.
remote: Counting objects: 100% (1597/1597), done.
remote: Compressing objects: 100% (272/272), done.
remote: Total 16905 (delta 1363), reused 1449 (delta 1304), pack-reused 15308
Receiving objects: 100% (16905/16905), 10.69 MiB | 12.13 MiB/s, done.
Resolving deltas: 100% (9949/9949), done.

(base) brunotechdatabasket@Brunos-MBP instantclient_19_8 % cd ~/oracle/OracleDatabase/SingleInstance/dockerfiles/
(base) brunotechdatabasket@Brunos-MBP dockerfiles % ls
11.2.0.2		12.2.0.1		18.4.0			21.3.0			buildContainerImage.sh
12.1.0.2		18.3.0			19.3.0			23.2.0


Ensure that Docker is running on your machine to avoid the following error: “errors pretty printing info Checking Docker version. Cannot connect to the Docker daemon at unix:///Users/brunotechdatabasket/.docker/run/docker.sock. Is the docker daemon running?”. If you haven’t installed Docker before, you can easily download it using the commands provided below:

$ brew install --cask docker
$ brew install git docker adoptopenjdk/openjdk/adoptopenjdk8

Once downloaded, you will be able to see the variety of Oracle versions that can be deployed using Oracle images.

(base) brunotechdatabasket@Brunos-MBP SingleInstance % cd dockerfiles 
(base) brunotechdatabasket@Brunos-MBP dockerfiles % ls -ltr
total 16
drwxr-xr-x   8 brunotechdatabasket  staff   256 May 18 20:38 11.2.0.2
drwxr-xr-x  18 brunotechdatabasket  staff   576 May 18 20:38 12.1.0.2
drwxr-xr-x  16 brunotechdatabasket  staff   512 May 18 20:38 12.2.0.1
drwxr-xr-x  16 brunotechdatabasket  staff   512 May 18 20:38 18.3.0
drwxr-xr-x   8 brunotechdatabasket  staff   256 May 18 20:38 18.4.0
drwxr-xr-x  19 brunotechdatabasket  staff   608 May 18 20:38 19.3.0
drwxr-xr-x  21 brunotechdatabasket  staff   672 May 18 20:38 21.3.0
drwxr-xr-x  12 brunotechdatabasket  staff   384 May 18 20:38 23.2.0
-rwxr-xr-x   1 brunotechdatabasket  staff  7562 May 18 20:38 buildContainerImage.sh

Since the goal is to deploy version 18.4, you can achieve this by executing the command “./buildContainerImage.sh” followed by the desired version. The database will then be deployed as shown below:

Successfully built d748b6e527b8
Successfully tagged oracle/database:18.4.0-xe


  Oracle Database container image for 'xe' version 18.4.0 is ready to be extended: 
    
    --> oracle/database:18.4.0-xe

  Build completed in 586 seconds.



With the image now ready to be extended, you can use the container to create the database, as shown below:

(base) brunotechdatabasket@Brunos-MBP dockerfiles % docker run --name oracle18.4.0-xe -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=abbaSweden123 -v /opt/oracle/oradata oracle/database:18.4.0-xe
...
ORACLE PASSWORD FOR SYS AND SYSTEM: abbaSweden123
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password: 
....
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
2023-05-18T21:40:17.891591+00:00
XEPDB1(3):Resize operation completed for file# 10, old size 358400K, new size 368640K
2023-05-18T20:21:35.824955+00:00
ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
2023-05-18T20:34:54.627387+00:00


The database is deployed with the default Oracle configurations, including the Container XE and the PDB XEPDB1. Additionally, it is worth noting that the SYS and SYSTEM passwords have been set as “abbaSweden123”, although they can be changed as shown below by using the script setPassword.sh:

(base) brunotechdatabasket@Brunos-MBP dockerfiles % docker exec oracle18.4.0-xe ./setPassword.sh dbaoracle
The Oracle base remains unchanged with value /opt/oracle

SQL*Plus: Release 18.0.0.0.0 - Production on Thu May 18 21:06:49 2023
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> 
User altered.

SQL> 
User altered.

SQL> 
Session altered.

SQL> 
User altered.

SQL> Disconnected from Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0


As shown in the example above, the previous password “abbaSweden123” was changed to “dbaoracle”.

To conclude this post, the next step will involve attempting a connection to the database. Additionally, this post will serve as a complement to an infrastructure where I will be utilizing Jupyter Notebook, the Python programming language, and ChatGPT.

(base) brunotechdatabasket@Brunos-MBP /bin % docker exec -it oracle18.4.0-xe /bin/bash    
bash-4.2# sqlplus sys/123456@//localhost:1521 as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Fri May 19 22:28:05 2023
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> select instance_name, status from V$INSTANCE;

INSTANCE_NAME	 STATUS
---------------- ------------
XE		 OPEN



References:

1. Oracle. (n.d.). Oracle Database Documentation. Retrieved from https://docs.oracle.com/en/database/

2. Docker. (n.d.). Docker Documentation. Retrieved from https://docs.docker.com/

3. Python Software Foundation. (n.d.). Python Documentation. Retrieved from https://docs.python.org/

4. Jupyter. (n.d.). Jupyter Documentation. Retrieved from https://jupyter.org/documentation

5. Oracle. (n.d.). Oracle Database Express Edition — How to install on macOS. Retrieved from https://boisv.medium.com/oracle-database-express-edition-how-to-install-on-macos-538f6404fefb

6.Oracle. (n.d.). Oracle Instant Client Downloads for macOS (Intel x86). Retrieved from https://www.oracle.com/se/database/technologies/instant-client/macos-intel-x86-downloads.html

7. Dell (n.d). Step 4: Build and run the Oracle 19c container on Docker. Retrieved from https://infohub.delltechnologies.com/l/oracle-in-docker-containers-managed-by-kubernetes-2/step-4-build-and-run-the-oracle-19c-container-on-docker-6

Related posts

One Thought to “Installing Oracle Database on macOS using Oracle Docker Images”

  1. Jaya Handika Darussalam

    Helo, where i should find the username?

Leave a Comment