Running Oracle DB
About
Running Oracle DB on a Mac (especially with Apple Silicon like M1/M2) can be tricky because Oracle doesn't officially support macOS. However, we can run it using Docker with the right setup. Below are our options:
Option 1: Using Manual Image Build
Use Oracle DB in Docker
Oracle provides official Docker images through GitHub.
Step 1: Clone Oracle Docker GitHub Repo
git clone https://github.com/oracle/docker-images.git
cd docker-images/OracleDatabase/SingleInstance/dockerfilesStep 2: Download Oracle Database Installation Zip
Go to the Oracle website and download the Oracle Database zip (for example: LINUX.X64_193000_db_home.zip for 19c).
Place the zip in the same folder where
buildContainerImage.shexists.
Step 3: Build Docker Image
./buildContainerImage.sh -v 19.3.0 -e-v 19.3.0: Version-e: Express Edition
This will build a Docker image like oracle/database:19.3.0-ee.
Step 4: Run the Oracle Container
We can replace ee with xe if we built the Express Edition image.
Step 5: Connect to Oracle
Using SQL Developer or DBeaver:
Host:
localhostPort:
1521SID:
ORCLCDBor Service Name:ORCLPDB1Username:
sysorsystemPassword:
MySecretPassword
Option 2: Use Prebuilt Docker Image (Unofficial)
If we don’t want to build it ourself, we can use an unofficial Oracle XE Docker image:
This image works on M1/M2 chips as well (
arm64).
Execute Image in a Container
Here is how to run the container and connect using SQL Developer.
Running the container without a volume means all data is lost when the container is removed.
Step 1: Run Oracle XE Docker Container
-p 1521:1521: For SQL connections (JDBC, SQL Developer, etc.)-p 8080:8080: Optional, for APEX/HTTP accessORACLE_PASSWORD: Sets the password for all users (e.g.,system,sys)
Step 2: Connect to Oracle using SQL Developer
Open SQL Developer and create a new connection:
Name
oracle-xe
Username
system (or sys with role SYSDBA)
Password
MySecretPassword
Hostname
localhost
Port
1521
Service Name
XEPDB1 (default)
If
XEPDB1doesn't work, tryXE(SID) — depends on the image version.
Click Test and it should say "Success".
To Check Running Status
Look for lines like:
SQL*Plus inside the container
Execute Image via Docker-Compose
Running the container without a volume means all data is lost when the container is removed. Here’s a docker-compose.yml file to run gvenzl/oracle-xe:18.4.0 with persistent storage using Docker volumes so that the data is persisted in volume.
docker-compose.yml
docker-compose.ymlvolumes: oracle_data:/opt/oracle/oradataThis maps a named Docker volume to Oracle's data directory (
/opt/oracle/oradata) to persist the database files.
restart: unless-stoppedEnsures the container restarts automatically after reboot/crash unless manually stopped.
How to Use
Save the file as
docker-compose.yml.Run the container:
Check logs:
Last updated