Using Docker for Java server-side development at the Oracle embedded JVM

This post is about using Docker for a controlled and secure development of Java at the Oracle Internal JVM (Java running inside your Oracle RDBMS, AKA OJVM).

Because Docker is most wanted/loved/used Development environment according to a recent StackOverflow survey:

and if you are involved in a big Java server side development which includes a lot Java code like Scotas Native Solr integration it will be a great time saving machine.
Following dev environment example have two big dependencies:

  • Oracle 19c RDBMS (EE or XE)
  • Apache Solr

Oracle 19c RDBMS is the target system for which Scotas OLS will be compiled and tested and Apache Lucene/Solr are the main component to be integrated as search engine running inside the RDBMS as new built-in domain index.
To prepare our dev/test Docker image We use a layered Docker image as:

ols-dev:2.0.5 layers

only green layer is our code to test/build, all the others are immutable layers which are part of the development environment, these are:

  • Oracle Linux 7 — slim from Docker Hub repo (as part of Oracle 19c build process)
  • 19c RDBMS Docker image build using Oracle’s official script
  • Extra tool/libraries required for compiling such as Apache Ant, JUnit and IVY
  • Internal libraries such as ODCI (wrapped classes for Data Cartridge package)
  • Apache Lucene/Solr from official SVN repository (patched)

a complete Dockerfile is available at GitHub, see below:


Build process
Before building above image, first check if you have the RDBMS image:

oracle@localhost:~$ docker image ls|grep 19.3.0-ee
oracle/database 19.3.0-ee a8bf34972c5c 6 months ago 6.5GB

next, build a dev docker image using:

oracle@localhost:~$ docker build -t "ols-dev:2.0.5" -f Dockerfile .
Sending build context to Docker daemon 34.82kB
Step 1/34 : FROM alpine:latest AS Solr40Source
---> 965ea09ff2eb
Step 2/34 : LABEL maintainer="Marcelo Ochoa <>"
---> Using cache
---> 991ef57d216b
Step 3/34 : RUN apk add --update subversion curl && rm -rf /var/cache/apk/*
......... rest of the build steps process output goes here .........
Step 34/34 : CMD exec /bin/bash
---> Using cache
---> 0fc0297527dd
Successfully built 0fc0297527dd
Successfully tagged ols-dev:2.0.5

Note immutable layers are taken from cache (except first build) so the image build process is about 5 seconds, this build time are perfect to include it in automatized CI/CD environment.

oracle@localhost:~$ docker image ls|grep ols-dev
ols-dev 2.0.5 0fc0297527dd 2 days ago 7.06GB

First, biggest goodness is that is a reproducible environment you can drop and build many times and you will get same result, second is fixed to an specific RDBMS, Solr and OLS code (using tagged branches), you could make different images changing BRANCH build argument, and finally you have all in one place to compile and build OLS.

Checking our dev/test environment
With above image ready, We can use it in Docker Swarm stack like is described in this docker-compose.yml file, note that the stack includes a service for the RDBMS, if We want to run some test against the DB, and a dev service defined with replicas=0, to start the environment simple run a command docker service scale ols_dev=1, a complete explanation on how to run above stack is explained in a Blog post OLS ready for installing at 19c using Docker + source code at GitHub.
Here an example of using our dev/test environment on Docker Swarm:

oracle@localhost:~/github/docker-images/ols-dev-env$ docker service scale ols_dev=1
ols_dev scaled to 1
overall progress: 1 out of 1 tasks
1/1: running [================================================>]
verify: Service converged
oracle@localhost:~/github/docker-images/ols-dev-env$ docker exec -ti ols_dev.1.kgp6cftzan2ouc997ddvqcmwd bash
[oracle@dev home]$ cd lucene
[oracle@dev lucene]$ ant build-modules
...... a lot of stuff here ......
[oracle@dev lucene]$ cd ../solr
[oracle@dev solr]$ ant dist-core dist-solrj dist-contrib
...... a lot of stuff here ......
[oracle@dev solr]$ cd ../ols
[oracle@dev ols]$ ant package-zip
...... building process goes here ......
[zip] Building zip: /home/lucene/build/
Total time: 1 minute 14 seconds

our build process ends without any errors!!! and it was compiled with a Java compiler certified for 19c ($ORACLE_HOME/jdk).

Extra functionalities for free
If you are using above Docker Swarm stack you have as extra:

  • a RDBMS to run JUnit test suites
[oracle@dev ols]$ ant test-queryhits-solr
Buildfile: /home/ols/build.xml
[echo] Building ols...
[junit] Running com.scotas.solr.indexer.TestQueryHits
[junit] Hits: 16282
..... test output goes here .....
[junit] Query time: 41
[junit] Elapsed time: 11296
[junit] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.692 sec
Total time: 12 seconds
  • a RDBMS to regenerate server side libraries such ODCI (this is obsolete in 19c dist by default and required to install OLS)
[oracle@dev ols]$ mkdir tmp
[oracle@dev ols]$ ant -Ddba.usr=sys -Ddba.pwd=pwd -Ddb.str=orclpdb1 generate-ODCI-jar
Buildfile: /home/ols/build.xml
[echo] Building ols...
..... rest of generation output here .....
[jar] Building jar: /home/ols/tmp/ODCI.jar
Total time: 34 seconds

Using an standalone environment
If you only want to compile the code is possible to start an ephemeral docker container with:

oracle@localhost:~/github/docker-images/ols-dev-env$ docker run -ti --rm ols-dev:2.0.5 bash
[oracle@3023358b5b05 home]$ cd lucene
[oracle@3023358b5b05 home]$ ant build-modules
[oracle@3023358b5b05 home]$ cd ../solr
[oracle@3023358b5b05 solr]$ ant dist-core dist-solrj dist-contrib
[oracle@3023358b5b05 solr]$ cd ../ols
[oracle@3023358b5b05 ols]$ ant package-zip
[zip] Building zip: /home/lucene/build/
Total time: 1 minute 13 seconds

and that’s all you will get same result, note once you exit from docker container everything is discarded.

Using live code
Usually you are working with a live code environment which means you are editing the code with your favorite code editor and want to compile with an immutable/reproducible process, for doing that just mount your external code directory in a docker container:

oracle@localhost:~/github/ols$ docker run -ti --rm -v $(pwd):/home/ols ols-dev:2.0.5 bash
[oracle@dffb524bf8d0 home]$ cd solr

a similar approach is when using Docker Swarm stack, you have to uncomment the stack code fragment:

- /home/oracle/github/ols:/home/ols # OLS source

have fun using Scotas OLS, Docker and Oracle.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store