In this post I’ll show you how to stand up a couple of Docker containers running Oracle Database Xe and Oracle REST Data Services.
I will assume you are familiar with using Docker. If not checkout this getting started guide.
Required Downloads
Oracle docker-images repository
Oracle provides a GitHub repository with a log of great examples. Clone repository into the directory where you want to work.
Oracle Xe
You can find more information about Oracle Xe at https://www.oracle.com/rest.
Download the installer and place it in the docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0 directory.
I’ll be using
oracle-database-xe-18c-1.0-1.x86_64.rpm .
Oracle Rest Data Services (ORDS)
You can find more information about ORDS at https://www.oracle.com/rest.
Download the installer and place it in the docker-images/OracleRestDataServices/dockerfiles directory.
I’ll be using
ords-19.1.0.092.1545.zip .
ORDS runs in Java, so you’ll need a Java JRE. Download the Server JRE and place it in the docker-images/OracleJava/java-8 directory.
I’ll be using
server-jre-8u211-linux-x64.tar.gz .
Docker Network
We’ll be running the database and ORDS in separate docker containers. Define a docker network that they will use to communicate.
|
docker network create OrdsXeNet |
Oracle Database Xe
Change into the docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0 directory. Make sure the Oracle Xe install file (oracle-database-xe-18c-1.0-1.x86_64.rpm) is in this directory.
This directory contains a Dockerfile.xe ready for us to use. Take a minute and read through the file to see what it is going to do.
Build the Oracle Database Docker Image
The repository includes a shell script (buildDockerImage.sh) that you can use to build the docker image for Xe and other Oracle Databases.
It can be found in the docker-images/OracleDatabase/SingleInstance/dockerfiles directory. Instructions for using this script can be found here.
I won’t be using the shell script.
The shell script will generate and run something similar to the following command that I will use:
*Notice the dot at the end, this is not a typo.
|
docker build --force-rm=true \ --no-cache=true \ --shm-size=1G \ --build-arg DB_EDITION=xe \ -t oracle/database:18.4.0-xe \ -f Dockerfile.xe . |
You can find an explanation of the Docker Build parameters here.
If this command doesn’t work for you, try using the shell script.
Verify that your image was created:
You should see something like this:
|
REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 18.4.0-xe a0ed1af72ac3 About a minute ago 8.57GB |
Once you have created the docker image it’s time to
Create a Docker Container
The following command is similar to the command you’ll find on the GitHub repository, but I’ve added a ‘-d’ to run the container in detached mode and I’m not defining any data volumes so my data will not persist when I delete the container.
You can find more information on the docker run command parameters here.
|
docker run -d \ --name oracleXe \ --network=OrdsXeNet \ -p 1521:1521 \ -p 5500:5500 \ -e ORACLE_PWD="Password1_One" \ oracle/database:18.4.0-xe |
This will take a few minutes.
You can watch the progress and troubleshoot any issues with with this command:
(You can use the container name or id.)
When the last line of the log looks like this, you are ready to proceed.
|
Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE |
Verify that your container was created and is up:
You should see something like this:
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1d0193197193 oracle/database:18.4.0-xe "/bin/sh -c 'exec $O…" 15 minutes ago Up 15 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp, 8080/tcp oracleXe |
Now try to connect to your new Oracle Xe Database.
To connect with SQLcl:
|
sql system/Password1_One@localhost:1521/xepdb1 SQLcl: Release 18.4 Production on Fri Apr 19 14:30:52 2019 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to: Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production Version 18.4.0.0.0 |
Oracle REST Data Services
Before we create the ORDS container, we need to create a Docker image with Oracle Linux 7 and a Java JRE installed. We will use this as a base image to build on top of.
Oracle Linux 7 and Java JRE Base Image
Change into the docker-images/OracleJava/java-8 directory. In there you will find a Dockerfile and the server-jre-8uXXX-linux-x64.tar.gz file you downloaded earlier.
Take a minute and read through the Dockerfile to see what it is going to do.
Run the following to build the image:
*Notice the dot at the end, this is not a typo.
|
docker build -t oracle/serverjre:8 . |
We do not need to create a Docker container from this image. We will only need the image as a base for the ORDS image.
Verify that your image was created:
You should see something like this:
|
REPOSITORY TAG IMAGE ID CREATED SIZE oracle/serverjre 8 2753451f0db2 2 seconds ago 270MB oracle/database 18.4.0-xe a80f034f2cf1 4 minutes ago 8.57GB |
Now we can create the ORDS image.
ORDS
Change into the docker-images/OracleRestDataServices/dockerfiles directory. In there you will find a Dockerfile and the ords-19.1.0.092.1545.zip file you downloaded earlier.
Take a minute and read through the Dockerfile to see what it is going to do.
Pre-Checks
Verify that the docker network we created earlier is ready:
You should see something like this.
|
NETWORK ID NAME DRIVER SCOPE b0d55a0755b9 OrdsXeNet bridge local |
Make sure your Xe database is running with the
docker ps command above.
If the Xe database container is not started, start it with the following command:
|
docker container start oracleXe |
Build the ORDS Docker Image
The repository includes a shell script (buildDockerImage.sh) that you can use to build the ORDS docker image.
It can be found in the docker-images/OracleRestDataServices/dockerfiles directory. Instructions for using this script can be found here.
If you choose to run the shell script instead of the below command, and there is not a Checksum file included for the version of ORDS you are installing, use the
-i 1 command line argument to ignore the check.
The shell script will generate and run something similar to the following:
*Notice the dot at the end, this is not a typo.
|
docker build --force-rm=true \ --no-cache=true \ -t oracle/restdataservices:19.1.0 \ -f Dockerfile . |
Verify that your image was created:
You should see something like this:
|
REPOSITORY TAG IMAGE ID CREATED SIZE oracle/restdataservices 19.1.0 67f7365e4fb4 6 seconds ago 394MB oracle/serverjre 8 2753451f0db2 5 minutes ago 270MB oracle/database 18.4.0-xe a80f034f2cf1 10 minutes ago 8.57GB |
Now we can create the ORDS container.
Create an ORDS Docker Container
The following command is similar to the command you’ll find on the GitHub repository, but I’ve added a ‘-d’ to run the container in detached mode and I’m not defining any data volumes so my data will not persist when I delete the container.
Make sure that you set
-e ORACLE_HOST=oracleXe to the name you used for the Oracle Xe Database container you created above. ORDS will not find your database if you use localhost. The containers are basically separate servers running on the same network
--network=OrdsXeNet .
The parameter
-e ORACLE_PWD="Password1_One" is the SYS/SYSTEM password you used when you created the Oracle Xe Database above.
The parameter
-e ORDS_PWD="ORDS_Password1" will be used as the ORDS admin password. It does not need to be the same as the database password.
|
docker run -d \ --name ORDS \ --network=OrdsXeNet \ -e ORACLE_HOST=oracleXe \ -e ORACLE_SERVICE=xepdb1 \ -e ORACLE_PWD="Password1_One" \ -e ORDS_PWD="ORDS_Password1" \ -p 8080:8888 \ oracle/restdataservices:19.1.0 |
Verify that your container was created and is up:
You should see something like this:
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0bd6a3cb2b56 oracle/restdataservices:19.1.0 "/bin/sh -c $ORDS_HO…" 48 seconds ago Up 46 seconds 0.0.0.0:8080->8888/tcp ORDS 720ec365868a oracle/database:18.4.0-xe "/bin/sh -c 'exec $O…" 19 minutes ago Up 19 minutes (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp, 8080/tcp oracleXe |
You should now have an Oracle Xe database up and running in one container and an ORDS instance running in the other.
Connect to your database and test that ORDS is properly installed and configured. A quick way to tell using Oracle SQL Developer is:
- Create a new database user.
- Connect as that user.
- Right click on the connection.
- Look towards the bottom of the menu for “REST Services”.
Have fun creating your new REST modules!
You must be logged in to post a comment.