#1
Oracle Database is a powerful and widely used relational database system, often seen in enterprise applications. Installing it traditionally can be a bit complex—but thanks to Docker, you can run OracleDB locally without the headache of full installation and system configuration.
In this guide, you’ll learn how to install and run OracleDB using Docker, step by step. We’ll cover pulling the image, setting up the container, and accessing OracleDB through command-line tools or graphical clients.

Why Use Docker for OracleDB?

Using Docker to run OracleDB is a great option, especially for development and testing, because it:
  • Simplifies installation
  • Keeps your system clean and isolated
  • Allows you to start and stop the database quickly
  • Runs the same across any system with Docker installed

Important Notes Before You Begin

Oracle does not publish an official Docker image on Docker Hub like other databases (e.g., MySQL or PostgreSQL). Instead, you need to:
  • Build the Docker image yourself using Oracle’s scripts OR
  • Use a trusted community image such as gvenzl/oracle-xe
In this tutorial, we’ll use the widely trusted gvenzl/oracle-xe image, which is fast and easy to set up for local development.

Prerequisites

Make sure Docker is installed.

Windows/macOS:

Download Docker Desktop from:
👉 https://www.docker.com/products/docker-desktop

Ubuntu/Linux:

sudo apt update && sudo apt install docker.io
Check that Docker is working:
docker --version

Step 1: Pull the Oracle XE Docker Image

Let’s pull the Oracle Express Edition image from Docker Hub:
docker pull gvenzl/oracle-xe
This will download a lightweight version of Oracle Database that’s perfect for local use.

Step 2: Run OracleDB in a Docker Container

Now start the container:
docker run -d \
  --name oracledb \
  -p 1521:1521 \
  -e ORACLE_PASSWORD=Oracle123 \
  gvenzl/oracle-xe

Breakdown of the command:

  • --name oracledb → container name
  • -p 1521:1521 → maps Oracle’s default port to your local machine
  • -e ORACLE_PASSWORD=Oracle123 → sets the password for the oracle user
  • gvenzl/oracle-xe → the image we’re running
  • -d → runs the container in the background

Step 3: (Optional) Use Volumes to Persist Data

If you want your OracleDB data to remain even after stopping the container, add a volume:
docker run -d \
  --name oracledb \
  -p 1521:1521 \
  -e ORACLE_PASSWORD=Oracle123 \
  -v oracledb-data:/opt/oracle/oradata \
  gvenzl/oracle-xe
This creates a named Docker volume (oracledb-data) to store your data persistently.

Step 4: Verify the Container is Running

Run the following to check:
docker ps
You should see your oracledb container running and listening on port 1521.
To view logs:
docker logs oracledb

Look for a message like:

DATABASE IS READY TO USE!

Step 5: Connect to OracleDB

Using SQL*Plus (if installed locally)

sqlplus system/Oracle123@localhost:1521/XEPDB1
  • system: system-level user
  • Oracle123: your password
  • XEPDB1: default pluggable database name in Oracle XE
Don't have SQL*Plus? Use tools like DBeaver, Oracle SQL Developer, or DataGrip.

Using a GUI Tool

Connection settings:
  • Host: localhost
  • Port: 1521
  • User: system or oracle
  • Password: Oracle123
  • Service Name: XEPDB1

Step 6: Manage Your Oracle Container

Task Command
Stop container docker stop oracledb
Start container docker start oracledb
View logs docker logs oracledb
Remove container docker rm -f oracledb
Remove volume docker volume rm oracledb-data

Docker Compose Example

Prefer Docker Compose? Here's a quick setup:
version: '3.8'
services:
  oracledb:
    image: gvenzl/oracle-xe
    container_name: oracledb
    ports:
      - "1521:1521"
    environment:
      ORACLE_PASSWORD: Oracle123
    volumes:
      - oracledb-data:/opt/oracle/oradata

volumes:
  oracledb-data:
Start it with:
docker-compose up -d

Best Practices

  • Always use strong passwords for production use
  • Use volumes to persist your data
  • Don’t expose port 1521 publicly unless needed
  • Use XEPDB1 as the default service name in Oracle XE

image quote pre code