How to Self-Host Oracle

Galaxy Glossary

How do I self-host Oracle Database using Docker?

Self-hosting Oracle means running an Oracle Database instance on your own infrastructure—laptop, on-prem server, or private cloud—rather than using Oracle Cloud services.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why self-host Oracle instead of using Oracle Cloud?

Self-hosting gives full control over backups, upgrades, and network access. Teams avoid recurring cloud fees and can tune storage, CPU, and memory to meet strict on-prem or air-gapped requirements.

What hardware and OS do I need?

For Oracle 21c XE, allocate at least 2 vCPUs, 4 GB RAM, and 20 GB disk. Linux x86-64 is preferred, but Windows and macOS work with Docker Desktop.

Which edition should I download?

Most developers choose Oracle Database Express Edition (XE): free, lightweight, and supports up to 12 GB user data. Production workloads may require Standard or Enterprise Edition licenses.

What is the fastest install method?

Docker cuts install time to minutes. Oracle maintains an official image on the Container Registry and Docker Hub. Pulling the image skips manual package dependencies and silent installs.

What is the exact Docker syntax?

docker run -d --name oracle-xe \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PWD=MyS3curePwd! \
-e ORACLE_SID=ORCLCDB \
-e ORACLE_PDB=ORCLPDB1 \
-v $HOME/oracle/oradata:/opt/oracle/oradata \
container-registry.oracle.com/database/xe:21.3.0

Ports 1521 (SQL*Net) and 5500 (EM Express) map to the host. The volume flag persists data between container restarts.

How do I connect and run SQL?

# via sqlplus inside the container
docker exec -it oracle-xe sqlplus system/MyS3curePwd!@ORCLCDB

# sample DDL in an ecommerce context
CREATE TABLE Customers (
id NUMBER PRIMARY KEY,
name VARCHAR2(100),
email VARCHAR2(150),
created_at DATE DEFAULT SYSDATE
);

Use any Oracle client: SQL*Plus, SQLcl, or GUI tools such as Galaxy.

How do I start, stop, and delete the instance?

docker stop oracle-xe
docker start oracle-xe
# remove the container but keep data volume
docker rm oracle-xe

Because data lives in $HOME/oracle/oradata, recreating the container re-attaches the existing data files.

How can I expose the database to my team?

Bind the Docker host to your LAN IP or use Kubernetes with a ClusterIP + Ingress. Configure Oracle Network ACLs and strong passwords before opening port 1521 beyond localhost.

Best practice — automate with Docker Compose

services:
oracle:
image: container-registry.oracle.com/database/xe:21.3.0
environment:
ORACLE_PWD: "+prodPwd123"
ports:
- "1521:1521"
volumes:
- ./oradata:/opt/oracle/oradata

Version-control the Compose file and feed secrets via environment variables.

Best practice — monitor health

Add the --health-cmd option to Docker or wire Prometheus exporters to alert when the listener stops responding.

Common mistakes and fixes

Insufficient shared memory: Oracle fails to start with ORA-00845 if /dev/shm is small. Add --shm-size=2g to docker run.

Ignoring license terms: Only XE is free in production. Confirm your edition and user limits to stay compliant.

Next steps

Create schemas for Orders, Products, and OrderItems, then connect Galaxy to your local listener to write optimized SQL with AI assistance.

Why How to Self-Host Oracle is important

How to Self-Host Oracle Example Usage


-- After connecting via sqlplus
CREATE TABLE Orders (
  id NUMBER PRIMARY KEY,
  customer_id NUMBER REFERENCES Customers(id),
  order_date DATE DEFAULT SYSDATE,
  total_amount NUMBER(10,2)
);

INSERT INTO Orders (id, customer_id, total_amount)
VALUES (1, 101, 99.99);

COMMIT;

How to Self-Host Oracle Syntax


docker run -d --name oracle-xe \
  -p 1521:1521 -p 5500:5500 \
  -e ORACLE_PWD=<password> \
  -e ORACLE_SID=<CDB name> \
  -e ORACLE_PDB=<PDB name> \
  -e ORACLE_CHARACTERSET=<AL32UTF8|other> \
  --shm-size=2g \
  -v /host/path/oradata:/opt/oracle/oradata \
  container-registry.oracle.com/database/xe:<version>

# Optional docker-compose
services:
  oracle:
    image: container-registry.oracle.com/database/xe:21.3.0
    environment:
      ORACLE_PWD: "prodPwd123"
      ORACLE_PDB: "ORCLPDB1"
    ports:
      - "1521:1521"
      - "5500:5500"
    shm_size: 2g
    volumes:
      - ./oradata:/opt/oracle/oradata

Common Mistakes

Frequently Asked Questions (FAQs)

Is Oracle XE really free for production?

Yes, but with limits: 2 CPUs, 12 GB user data, 2 GB RAM, and one instance per host. Anything beyond that requires Standard or Enterprise licenses.

Can I run multiple Oracle containers?

Yes. Map unique host ports (e.g., 1522, 1523) and distinct ORACLE_SID values. Ensure each container uses a separate volume for data.

How do I upgrade the image?

Pull the new tag, stop the old container, and start a new one pointing to the same data volume. Always back up oradata first.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.