Wednesday, July 10, 2024

Setting Up Oracle 23ai in a Docker Container Using the Free Edition for Linux

 Setting Up Oracle 23ai in a Docker Container Using the Free Edition for Linux


In the world of database management, Oracle 23ai stands out with its advanced features and capabilities. Setting it up in a Docker container is a great way to leverage these features in a scalable and isolated environment. This guide will walk you through the steps to set up Oracle 23ai Free Edition for Linux in a Docker container.

Prerequisites

Before we begin, ensure you have the following installed:

  • Docker
  • Docker Compose (optional, but recommended)

For this guide, we will be using Oracle Linux 8 as the Linux distribution. You can download and install Oracle Linux from the official Oracle Linux download page.

Step 1: Downloading the Latest Oracle 23ai Docker Image

Header: Downloading the Latest Oracle 23ai Docker Image

Oracle provides a pre-built Docker image for Oracle 23ai Free Edition. You can download the latest version of this image from the Oracle Container Registry or Docker Hub. Here’s how:


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

This command will download the latest version of the Oracle 23ai Free Edition Docker image to your system.

Step 2: Create a Docker Network

Header: Creating a Docker Network

It’s good practice to create a dedicated Docker network for your database container. This network will allow you to easily connect to the database from other containers.


docker network create oracle_network

This command creates a new Docker network named oracle_network.

Step 3: Run the Oracle 23ai Container

Header: Running the Oracle 23ai Container

Now, let’s run the Oracle 23ai container. Replace <password> with a strong password of your choice:


docker run -d --name oracle23ai \ --network=oracle_network \ -p 1527:1521 \ -e ORACLE_SID=FREE \ -e ORACLE_PDB=FREEPDB1 \ -e ORACLE_PWD=YourStr0ngP@$$W0rD \ -v oracle_data:/opt/oracle/oradata \ container-registry.oracle.com/database/free:latest

This command will start a new container named oracle23ai with the specified environment variables and port mappings. The -v oracle_data:/opt/oracle/oradata option ensures that your data is stored in a Docker volume named oracle_data.

Step 4: Verify the Container is Running

Header: Verifying the Container

Check if the container is running by executing:


docker ps



You should see a container named oracle23ai in the list. If the container is running, it means your Oracle 23ai database is up and running in the Docker container.

Step 5: Connect to the Oracle Database

Header: Connecting to the Oracle Database

You can connect to the Oracle database using SQLPlus, Oracle SQL Developer, or any other SQL client. 


Here is one with using VSCode with the Oracle SQLDeveloper Extension for VS Code



Step 6: Persist Data with Docker Volumes

Header: Ensuring Data Persistence

To ensure your data persists across container restarts, we’ve already used a Docker volume in the docker run command (-v oracle_data:/opt/oracle/oradata). This volume stores the Oracle data files on your host machine, ensuring that your data is not lost when the container is stopped or removed.

Step 7: Managing the Oracle Container

Header: Managing the Oracle Container

Here are a few useful Docker commands for managing your Oracle container:

  • Stop the container:

    docker stop oracle23ai


  • Start the container:

    docker start oracle23ai


  • Remove the container:


    docker rm -f oracle23ai


These commands allow you to easily manage the lifecycle of your Oracle 23ai container.

Conclusion

Setting up Oracle 23ai in a Docker container is a straightforward process that allows you to leverage Oracle’s powerful database capabilities in a flexible and isolated environment. With this setup, you can easily manage your database, ensuring data persistence and smooth operation.

Happy databasing!

No comments:

Post a Comment

QuickStart: Build an App Using an Excel Spreadsheet in Oracle APEX

  QuickStart: Build an App Using an Excel Spreadsheet in Oracle APEX Oracle APEX (Application Express) makes it incredibly easy to turn an E...