Oracle 23c Free Docker, APEX & ORDS all in one simple guide

Oracle 23c Free Docker, APEX & ORDS all in one simple guide

Up and running with APEX in 23c

The VM Appliance already contains these tools, however this guide provides the tools required to get up and running with APEX in docker.

The guide provides:

  • Oracle 23c Free Database

  • ORDS latest (23.1 at time of writing)

  • Open JAVA 17 JDK

  • APEX latest (22.2 at time of writing)

If you are quick at copy/pasting, you can rattle through the setup in 30mins - from step 3

Let's start...

  1. Mac: Install Brew/Colima/Docker by following this guide by Rafal first before continuing
    Windows: Ensure Docker is running & start Docker Desktop
    Unix: Ensure Docker is installed or install it below

     docker version
    

    or install it like this

     sudo yum install docker -y
    
  2. Drop in to command line (i.e terminal or windows+r, cmd) and type the following (it'll take about 15mins to complete) and it'll unpack to 10.5GB on your HDD

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

    It will look like this when complete

  3. Then we need to run it... (I changed ports to 8xxx to avoid conflicts with my other docker images).

     docker run -d -it --name 23cfree -p 8521:1521 -p 8500:5500 -p 8023:8080 -p 9043:8443 -p 9922:22 -e ORACLE_PWD=E container-registry.oracle.com/database/free:latest
    
  4. Now we enter bash

     docker exec -it 23cfree /bin/bash
    
  5. Then run this to get APEX (1min)

     curl -o apex-latest.zip https://download.oracle.com/otn_software/apex/apex-latest.zip
    
  6. unzip it & enter the apex folder (1min)

     unzip apex-latest.zip
     rm apex-latest.zip
     cd apex
    
  7. Make a coffee - seriously, let the DB settle for a few mins.

  8. Open SQL*Plus with sqlplus / as sysdba

     sqlplus / as sysdba
    

    like this...

     bash-4.4$ sqlplus / as sysdba
    
     SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Wed Apr 5 13:27:32 2023 Version 23.2.0.0.0
    
     Copyright (c) 1982, 2023, Oracle. All rights reserved.
    
     Connected to: Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release Version 23.2.0.0.0
    
  9. Set the PDB

     ALTER SESSION SET CONTAINER = FREEPDB1;
    

    Then run the APEX installer below. This will install APEX (10mins). Note if you get a PLS-00201: identifier 'SYS.DBMS_DB_VERSION' must be declared error, just keep re-trying this step until it works. It'll settle down within a few minutes.

     @apexins.sql SYSAUX SYSAUX TEMP /i/
    
  10. Unlock the public user account

    ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK;
    

    Then change the password

    ALTER USER APEX_PUBLIC_USER IDENTIFIED BY E;
    
  11. Change the password. Run the following and follow the steps. Note: you must use a complex password

    @apxchpwd.sql
    
  12. Type exit to exit SQL*Plus

  13. Make these folders

    mkdir /home/oracle/software
    mkdir /home/oracle/software/apex
    mkdir /home/oracle/software/ords
    mkdir /home/oracle/scripts
    
  14. Copy the APEX images & change folder

    cp -r /home/oracle/apex/images /home/oracle/software/apex
    cd /home/oracle/
    
  15. Drop in to superuser

    su
    

    Then install sudo

    dnf update -y
    dnf install sudo -y
    
  16. install nano

    dnf install nano -y
    
  17. Edit the sudo list

    nano /etc/sudoers
    

    in the Defaults section add

    Defaults !lecture
    

    At the very end of the file add

    oracle ALL=(ALL) NOPASSWD: ALL
    

    Ctrl+X and save the file

  18. Install JAVA (3mins)

    dnf install java-17-openjdk -y
    
  19. Setup ORDS folders & check JAVA - 1min

    mkdir /etc/ords
    mkdir /etc/ords/config
    mkdir /home/oracle/logs
    chmod -R 777 /etc/ords
    java -version
    

    This should say...

    openjdk version "17.0.6" 2023-01-17 LTS
    OpenJDK Runtime Environment (Red_Hat-17.0.6.0.10-3.el8_7) (build 17.0.6+10-LTS)
    OpenJDK 64-Bit Server VM (Red_Hat-17.0.6.0.10-3.el8_7) (build 17.0.6+10-LTS, mixed mode, sharing)
    
  20. Whilst still as su, Install ORDS

    yum-config-manager --add-repo=http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64
    dnf install ords -y
    
  21. Then configure ORDS

    export _JAVA_OPTIONS="-Xms512M -Xmx512M"
    ords --config /etc/ords/config install
    
  22. Use the following configuration

    Installation Type > Choose option [2] Enter
    Connection Type > Choose option [1] Enter
    host name > Enter
    listen port > Enter
    service name > FREEPDB1
    administrator username > SYS
    password > E
    default tablespace > Enter
    temp tablespace > Enter
    features > Enter
    Start ORDS > [1] Enter <-- Standalone Mode
    protocol > [1] < http
    port > [1] <-- 8080
    Static Resources > /home/oracle/software/apex/images
    

    ORDS will then configure. It will take 1-2 mins and finally load and finally show...

    Oracle REST Data Services version : 23.1.0.r0861423
    Oracle REST Data Services server info: jetty/10.0.12
    Oracle REST Data Services java info: OpenJDK 64-Bit Server VM 17.0.6+10-LTS
    
  23. Do a quick test in a new browser tab localhost:8023/ords/apex and then close the tab down.

    FYI: Prior to ORDS 23.2 (read here), you just use the URL localhost:8023/ords

  24. Ctrl+C to quit ORDS

  25. Create a start_ords.sh file

    nano /home/oracle/scripts/start_ords.sh
    

    Then paste in

    export ORDS_HOME=/usr/local/bin/ords
    export _JAVA_OPTIONS="-Xms512M -Xmx512M"
    LOGFILE=/home/oracle/logs/ords-`date +"%Y""%m""%d"`.log
    nohup ${ORDS_HOME} --config /etc/ords/config serve >> $LOGFILE 2>&1 & echo "View log file with : tail -f $LOGFILE"
    
  26. Create a stop_ords.sh file

    nano /home/oracle/scripts/stop_ords.sh
    

    Then paste in

    kill `ps -ef | grep [o]rds.war | awk '{print $2}'`
    
  27. FYI - DON'T RUN THIS NOW : You can run them manually like this (as su)

    # Commented for Reference 
    # sh /home/oracle/scripts/start_ords.sh
    # sh /home/oracle/scripts/stop_ords.sh
    
  28. Create an ORDS startup script

    nano /opt/oracle/scripts/startup/01_auto_ords.sh
    

    paste in the below

    sudo sh /home/oracle/scripts/start_ords.sh
    
  29. Type exit to quit out of docker and back to your local machine.

    exit
    
  30. If you are using docker on Unix (i.e not Windows/Mac), you'll need to enable linger (source #17)

    loginctl enable-linger $UID
    
  31. Stop your docker container (I like using the GUI) & then start it again.. this is to activate the auto ords starter script we just created

    docker restart 23cfree
    
  32. Wait 60 seconds, then try logging in at
    localhost:8023/ords/apex

    Workspace > INTERNAL
    Username > ADMIN
    Password > The Complex Password
    
  33. ENJOY!