Run Oracle 23ai as a Free Autonomous DB Container on MacBook Pro

Shadab Mohammad
Oracle Developers
Published in
4 min readMay 6, 2024

Deploy a docker container for the new Oracle 23ai database and get started with vector data types and 300+ new features in a matter of minutes

The article first appeared on : https://easyoradba.com/2024/05/03/run-oracle-23ai-as-a-free-autonomous-db-container-on-your-mac/

Oracle has launched a new database with AI incorporated into the database. Oracle Database 23c is rebranded as Oracle 23ai. It is currently available to download and also comes as a free container image for Autonomous Database.

In this blog, we will deploy the free 23ai ADB container on a MacBook Pro 💻 in this post :

1. Install Podman on your MacOS

brew install podman

2. Startup Podman on your Mac with Intel chip

podman machine init
podman machine set --cpus 4 --memory 8192
podman machine start

If you have a Mac with M1/M2/M3 chips then install Colima + Docker, and replace all podman commands wIth docker

# For M1/M2/M3 Macs

brew install docker
brew install docker-compose
brew install colima
brew reinstall qemu
colima start --cpu 4 --memory 8 --arch x86_64

## Make sure you don’t have a previous container called ‘adb-free’ running. In case it is; just remove it using command ‘docker container rm <container-id>’

If the container is not starting and you’re getting below error :

docker logs adb-free

TIME ELAPSED Unzipping /u01/POD1.zip: 1 minutes and 11 seconds elapsed
User input JSON not found
PermissionError: [Errno 13] Permission denied: '/u01/data/input.json'

# Then create the volume on your host machine and assign permissions as below :

mkdir -p /Users/shadab/Downloads/u01/data
chmod -R 775 /Users/shadab/Downloads/u01/data

docker container rm <container-id>

Re-run

docker run -d \
-p 1521:1522 \
-p 1522:1522 \
-p 8443:8443 \
-p 27017:27017 \
-e WORKLOAD_TYPE=ATP \
-e WALLET_PASSWORD=YourP@ssword321#_ \
-e ADMIN_PASSWORD=YourP@ssword321#_ \
--cap-add SYS_ADMIN \
--device /dev/fuse \
--volume adb_container_volume:/Users/shadab/Downloads/u01/data \
--name adb-free \
container-registry.oracle.com/database/adb-free:latest-23ai


docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a838dc47e3c container-registry.oracle.com/database/adb-free:latest-23ai "/bin/bash -c /u01/s…" 7 minutes ago Up 7 minutes (healthy) 0.0.0.0:1522->1522/tcp, :::1522->1522/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp, 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp, 0.0.0.0:1521->1522/tcp, :::1521->1522/tcp adb-free

Then proceed with the same steps as below skipping the first podman command.

3. Deploy the ADB 23ai container

#For INTEL Macs

podman run -d \
-p 1521:1522 \
-p 1522:1522 \
-p 8443:8443 \
-p 27017:27017 \
-e WORKLOAD_TYPE=ATP \
-e WALLET_PASSWORD=YourP@ssword321#_ \
-e ADMIN_PASSWORD=YourP@ssword321#_ \
--cap-add SYS_ADMIN \
--device /dev/fuse \
--volume adb_container_volume:/u01/data \
--name adb-free \
container-registry.oracle.com/database/adb-free:latest-23ai

#For M1/M2/M3 Macs

docker run -d \
-p 1521:1522 \
-p 1522:1522 \
-p 8443:8443 \
-p 27017:27017 \
-e WORKLOAD_TYPE=ATP \
-e WALLET_PASSWORD=YourP@ssword321#_ \
-e ADMIN_PASSWORD=YourP@ssword321#_ \
--cap-add SYS_ADMIN \
--device /dev/fuse \
--volume adb_container_volume:/Users/shadab/Downloads/u01/data \
--name adb-free \
container-registry.oracle.com/database/adb-free:latest-23ai

4. Check the container status, add database, change password and connect to it

$ podman container ls
CONTAINER ID  IMAGE                                                        COMMAND     CREATED        STATUS                  PORTS                                                                                             NAMES
ecfc957e782b container-registry.oracle.com/database/adb-free:latest-23ai 5 minutes ago Up 5 minutes (healthy) 0.0.0.0:1521->1522/tcp, 0.0.0.0:1522->1522/tcp, 0.0.0.0:8443->8443/tcp, 0.0.0.0:27017->27017/tcp adb-free

Create alias for adb-cli

$ alias adb-cli="podman exec ecfc957e782b adb-cli"

#ecfc957e782b is the container id returned from 'podman container ls'

#For Apple Silicon(M1/M2/M3 Macs)

$ alias adb-cli="docker exec adb-free adb-cli"
$ adb-cli --help# Add Databaseadb-cli add-database --workload-type "ADW" --admin-password "YourP@ssword321#_"# Change Passwordadb-cli change-password --database-name "MYADW" --old-password "YourP@ssword321#_" --new-password "WelcomeP@ssword321#_"

Access APEX :

https://localhost:8443/ords/myadw/apex

Access SQL Developer Web :

https://localhost:8443/ords/myadw/sql-developer

Username : ADMIN

Password : WelcomeP@ssword321#_

Important Note : use the URL formats https://localhost:8443/ords/{database_name}/apex and https://localhost:8443/ords/{database_name}/sql-developer to access APEX and Database Actions respectively.

Download Wallet and Connect with sqlcl

#Install sqlcl on your Mac
brew install sqlcl

# Add below to your bash or zsh profile
export PATH=/usr/local/Caskroom/sqlcl/24.1.0.087.0929/sqlcl/bin:"$PATH"

sql -v

# Copy the Wallet to your local machine
mkdir -p /Users/shadab/Downloads/wallet_adb_free_container
cd /Users/shadab/Downloads/wallet_adb_free_container
podman cp ecfc957e782b:/u01/app/oracle/wallets/tls_wallet ./

#You can now see a folder called 'tls_wallet', which has the wallet files of the ADB
#Export TNS_ADMIN variable with the location of the wallet and add to your bash or zsh profile
export TNS_ADMIN='/Users/shadab/Downloads/wallet_adb_free_container/tls_wallet'

#Check tnsnames.ora file in the tls_wallet folder for the tns entry for your ATP
cd tls_wallet/
ls -ltr
cat tnsnames.ora
echo $TNS_ADMIN

# Connect with sqlcl using the tns entry

sql ADMIN@myadw_high

SQL> select instance_name from gv$instance;

INSTANCE_NAME
________________
POD1

5. Test with Python3.11

For this test, we will convert some strings and numbers to a vector and save it as a vector datatype in Oracle 23ai

Install Python oracledb driver to interact with our Oracle 23ai ADB container

python3.11 -m pip install oracledb
python3.11 -m pip install PyPDF2
python3.11 -m pip install openai==0.28
python3.11 -m pip install numpy

$ vim connect.py

import oracledb
conn = oracledb.connect(user="ADMIN", password="WelcomeP@ssword321#_", dsn="myadw_high", config_dir="/Users/shadab/Downloads/wallet_adb_free_container/tls_wallet", wallet_location="/Users/shadab/Downloads/wallet_adb_free_container/tls_wallet", wallet_password="WelcomeP@ssword321#_")
cr = conn.cursor()
r = cr.execute("SELECT 1 FROM DUAL")
print(r.fetchall())
$ python3.11 connect.py
[(1,)]

For more Oracle 23ai vector code for Python3, check put this Github Repo : https://github.com/shadabshaukat/oracle23ai-python.git

--

--

Shadab Mohammad
Oracle Developers

Cloud Solutions Architect@Oracle (The statements and opinions expressed here are my own & do not necessarily represent those of my employer)