Oracle XE and Apex in a docker container

luca bindi
5 min readOct 5, 2021

Let me do an introduction saying that you can use Oracle database with oracle APEX directly on Oracle Cloud, and that’s should be the first choice because it’s easy, it’s free (you can use Oracle Free Tier ) and run on an autonomous service that is super secure and always updated database🙂

Furthermore, you don’t have to take care or give up your laptop’s resources!!

But anyway if I haven’t convinced you and you still want a database on your laptop, for example on a Macbook this is a very fast procedure to build it in a docker enviroment.

Install Docker Desktop

first of all, you have to install docker desktop on your mac

so download the software and install it

download docker desktop img from https://docs.docker.com/desktop/mac/install/

It’s better to change the Docker default memory setting if we want to host both Oracle Database and Oracle Apex

Oracle XE docker

To have the Oracle XE in a container you have to go to Oracle Registry web site

https://container-registry.oracle.com/ords/f?p=113:10::::::

and after creating a free account, choose the database section as in this picture

in that section, you will find instructions about how to install Oracle XE as I did below with a little change.

Ok now we have the docker desktop on our laptop, we have to open a terminal window and access the Oracle registry using the previously created user

docker login container-registry.oracle.com

Now you can execute the pull command to download your XE database image

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

It’s better to create a network in a docker environment so our dockers can communicate with other dockers using a hostname

docker network create ords-database-network

At this point, we have done all that we need and we can execute the command to run our Oracle Database XE in a docker on our laptop.

docker run -d --name testapex --hostname database --network=ords-database-network -p 1521:1521 container-registry.oracle.com/database/express:latest

please note I used the parameter name, hostname and network.

If you want to connect by sqlplus you can execute this command

docker exec -it -u oracle testapex sqlplus / as sysdba

With the “show pdbs” command you will check the status of your pdbs

show pdbsCON_ID CON_NAME OPEN MODE RESTRICTED
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
2 PDB$SEED READ ONLY NO
3 XEPDB1 READ WRITE NO

Change the default password using the below command (in my case the password is Welcome1##)
(NB before execute this command please be sure the pdb XEPDB1 is open in read and write)

docker exec testapex ./setPassword.sh Welcome1##

APEX and Ords

If you also want Apex for your Oracle XE installation in docker, just follow these further steps

From the terminal session pull the image of ords, remember you have been connected with the Oracle Registry (if your session was expired)

docker login container-registry.oracle.com

then execute the pull command to download the ords image

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

To configure the Apex installation we have to create a directory on our laptop

mkdir ~/APEX

and put the string information inside a file on this directory

echo ‘CONN_STRING=sys/Welcome1##@database:1521/XEPDB1’ > ~/APEX/conn_string.txt

please note I used the parameter hostname of Oracle Database XE docker and the service of the pdb for the string connection.

CONN_STRING variable needs to be in below shape (without single quote that can happen if you are using bash shell ): CONN_STRING=user/password@host:port/service_name

At this point, you can run the docker

docker run --rm --name apex -v /Users/lbindi_it/APEX:/opt/oracle/variables --network=ords-database-network -p 8181:8181 container-registry.oracle.com/database/ords:latest

also here please note I used the same parameter network.

To monitor the installation, you can open another terminal session and execute this command

docker run — rm — name apex -v /Users/lbindi_it/APEX:/opt/oracle/variables — network=ords-database-network -p 8181:8181 container-registry.oracle.com/database/ords:latest

Change the password for APEX_PUBLIC_USER user inside the database; To do that login in a Oracle XE docker by sqlplus

sqlplus sys/Welcome1##@//localhost:1521/XEPDB1 as sysdba

and set the password

alter user APEX_PUBLIC_USER identified by Welcome1##;

Now you can connect to your Apex enviroment

to connect at Apex use this http://localhost:8181/ords

use this information to log-in an internal workspace

- Workspace: internal- User: ADMIN- Password: Welcome_1

As you can see it’s very simple to have Oracle Xe and Apex in a docker environment.
Finally let me say that Oracle XE offers a lot of free important features, here just some of them, these features allow you to develop and test your application using a different type of data and workload (spatial, graph multitenant, JSON etc etc)

I hope it’s useful and … have fun

Ciao.
Luca

Disclaimer

The views expressed on this paper are my own and do not necessarily reflect the views of Oracle.

useful link  (thanks Gerald)
https://medium.com/oracledevs/creating-an-oracle-database-docker-image-f3cea1ea21bb

--

--