Oracle Database Express Docker edition installation guide

|
|
Tags:  Oracle,  Docker

In this guide you will learn how to install Oracle Database Express (XE) 21c Docker edition and the Oracle Sample Database Schemas. It is intended to get a test environment as quick as possible so don’t expect to learn any of best practices.

The commands were run in a computer with Windows 11, but also can be run with little modifications on other operating systems.

Install Oracle Express Docker edition

  1. First create the folder C:\oracle_data.
  2. Now open a Poweshell terminal and run this command that creates the Oracle Express database container. Also, it sets the password to ORACLE for users: sys, system, and pdbadmin, and configures the volume /opt/oracle/oradata to store the database files in C:\oracle_data.
      docker run --name OracleXE_Server `
      -d `
      -e ORACLE_PWD=ORACLE `
      -v C:\oracle_data:/opt/oracle/oradata `
      container-registry.oracle.com/database/express:21.3.0-xe
    
  3. After, execute periodically the command docker container ps until the container status changes to healthy.

The next steps are to check Oracle database is up and running:

  1. First, check that C:\oracle_data folder is not empty.
  2. Connect to the terminal of the container: docker exec -it OracleXE_Server bash
  3. Run sqlplus command to connect to the Oracle server: sqlplus / as sysdba
  4. Finally, execute a query to test the database. For example, this one that shows the list of databases: select name from V$database;

(Optional) Install Oracle sample schemas

The sample schemas are the official Oracle example data for learning and testing purposes.

  1. Download the Oracle Database Sample Schemas 21c zip file and unzip it in the folder C:\db-sample-schemas-21.1
  2. Copy the files to a temporary folder inside the Oracle database server container: docker cp C:\db-sample-schemas-21.1 OracleXE_Server:/tmp/
  3. Replace the string __SUB__CWD__ with /tmp/db-sample-schemas-21.1 in all Oracle sample schema files:
    docker exec -it --user root -w /tmp/db-sample-schemas-21.1 OracleXE_Server bash -c "find . -type f -exec sed -i 's/__SUB__CWD__/\/tmp\/db-sample-schemas-21.1/g' {} +"
  4. Open a console in the container in /tmp/db-sample-schemas-21.1 folder: docker exec -it -w /tmp/db-sample-schemas-21.1 OracleXE_Server bash
  5. Connect to the Oracle server as admin: sqlplus / as sysdba
  6. Run this command to install the Oracle Sample schemas. It will set the password to ORACLE for all schemas (HR, OE, PM, IX, SH, and BI):
    @mksample ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE ORACLE users temp /opt/oracle/oradata/logs XEPDB1

The next steps are to check Oracle sample schemas are installed:

  1. Open a console in the container in /tmp/db-sample-schemas-21.1 folder:
    docker exec -it -w /tmp/db-sample-schemas-21.1 OracleXE_Server bash
  2. Connect to the Oracle server as admin: sqlplus / as sysdba
  3. Run this command to list the sample schemas. It must return 6 rows:
    SELECT username FROM all_users WHERE username IN ('HR', 'OE', 'PM', 'IX', 'SH', 'BI');

Uninstall Oracle Express Docker edition

  1. Run the command docker container stop OracleXE_Server to stop Oracle Database
  2. Run docker container rm OracleXE_Server to delete the container
  3. (Optional) Delete the folder C:\oracle_data to destroy the database and all settings of the Oracle server.

Sources

Author

Sergio Monedero

DevOps engineer, Systems Administrator, and Developer. I enjoy staying up to date on the latest technology trends. This is my personal website where I share my knowledge and insights.

You can also follow me on LinkedIn as SergioCoder, or Github as Branyac