Run Oracle Database 21c in Docker

Venkatesh Prabhu
Geek Culture
Published in
4 min readDec 7, 2022

A quick guide to deploy Oracle Database as a container in Docker (Windows)

Overview

In this blog, we are going to look at how to quickly setup an Oracle 21c Database for development or learning purposes using Docker. This guide will come in handy when you are planning to use Oracle as a database for your Proof-of-Concept (PoC) or for exploring its features.

Flow

  • Review Docker installation
  • Docker Hub — Authentication
  • Pull the Docker Image
  • Create & run the container
  • Connect to the database

Review Docker Installation

If you have not installed Docker Desktop in your machine, you can install it by going through the official documentation from Docker.

Once we have installed it, we can go to the command prompt and issue the following command to ensure everything went well during installation.

Installed version of Docker

Docker Hub — Authentication

We need a Docker Hub account to perform the next step and you can create one here — Docker Hub

Once we have the credentials, execute the following command to login.

docker login
Login to Docker Hub

Pull the Docker Image

We can pull the image using this docker pull command. This will pull the latest update from the official container registry of Oracle. We are using the Express edition in this blog similarly other editions are also available.

docker pull container-registry.oracle.com/database/express:latest

If you are interested in a specific version of the database, we can mention it like docker pull container-registry.oracle.com/database/express:21.3.0-xe

Pull the Oracle DB Image

For me it did not ask for the Oracle credentials as the image has already been downloaded. But if you are doing it for the first time then it will prompt for your Oracle account credentials.

Create & run the container

Once we have pulled the image, we can create a Docker container based on that image.

Syntax

docker container create `
-it ` # Run the container in interactive mode
--name [container-name] ` # Name of the container
-p [host-port]:1521 ` # Map the port from host to container for DB
-e ORACLE_PWD=[custom-pass] ` # Password for default user
container-registry.oracle.com/database/express:[version] # Image


Example

docker container create `
-it `
--name oracle-test `
-p 1521:1521 `
-e ORACLE_PWD=welcome123 `
container-registry.oracle.com/database/express:latest
Confirmation of container creation

The backtick (`) symbol is used to break the line for readability purposes

Once the container is created, we can use the docker start [container-name] or docker stop [container-name] command to start or stop the container.

Start the container

Connect to the database

We can now connect to our newly created database using the default credentials in SQL Developer or any other SQL editors.

Database Info

host: localhost
port: 1521
username: system
password: welcome123
sid: xe
Connect using SQL Developer

PS: Hope you were able to follow-up with this tutorial and if you are facing any challenges or if you have any suggestions, please leave a comment below.

References

Oracle Container Registry: Explore Oracle Repositories

Oracle Database Express Edition — Repository Detail

If you like the article and would like to support me make sure to:

  • 👏 Clap for the story (50 claps)
  • 📰 View more content on my medium profile
  • 🔔 Follow Me: LinkedIn | Medium | GitHub
  • 🚀 Join the Medium membership program to continue learning without limits by joining through the below link.

--

--

Venkatesh Prabhu
Venkatesh Prabhu

Written by Venkatesh Prabhu

I Read. I Explore. I Understand. I Share. I Motivate.

Responses (3)