Build Oracle Graph on Docker (Part 2/2, version 22.4 and above)

Ryota Yamanaka
4 min readJan 30, 2023

(The procedure below was tested with versions 22.4.2 and 23.1.0.)

In Part 1, I explained how to run Oracle Database on a container and use it as a graph database. There are various ways to use it in this environment alone, such as converting table data to graphs, creating views, and even combining it with JSON, which I will introduce in the future.

However, this article will focus only on explaining the procedure to build and add a container for Graph Server. In the architecture diagram below, we have already built the 2-tier deployment, and now we will add the 3-tier deployment.

Building the Graph Server

Download the RPM package that contains Graph Server from this site. When you select the package below, you will be asked to agree to the license and log in with your Oracle account.

In addition, download JDK 11 (Linux — x64 RPM Package) from this site. There is no license fee for personal or development use.

Place these RPM packages and the Dockerfile you will create next in the same directory.

  • oracle-graph-23.1.0.x86_64.rpm
  • jdk-11.0.17_linux-x64_bin.rpm
vi Dockerfile

This is a sample Dockerfile.

FROM oraclelinux:7

ARG VERSION_JDK
ARG VERSION_OPG
ARG JDBC_URL

COPY ./jdk-${VERSION_JDK}_linux-x64_bin.rpm /tmp
COPY ./oracle-graph-${VERSION_OPG}.x86_64.rpm /tmp

RUN yum install -y unzip numactl gcc libgfortran \
&& yum clean all \
&& rm -rf /var/cache/yum/* \
&& rpm -ivh /tmp/jdk-${VERSION_JDK}_linux-x64_bin.rpm \
&& rpm -ivh /tmp/oracle-graph-${VERSION_OPG}.x86_64.rpm

ENV JAVA_HOME=/usr/java/jdk-${VERSION_JDK}
ENV PATH=$PATH:/opt/oracle/graph/bin
ENV SSL_CERT_FILE=/etc/oracle/graph/ca_certificate.pem
ENV PGX_SERVER_KEYSTORE_PASSWORD=changeit

RUN keytool -importkeystore \
-srckeystore /etc/oracle/graph/server_keystore.jks \
-destkeystore $JAVA_HOME/lib/security/cacerts \
-deststorepass changeit \
-srcstorepass changeit \
-noprompt

RUN sed -i "s|<REPLACE-WITH-DATABASE-URL-TO-USE-FOR-AUTHENTICATION>|${JDBC_URL}|" /etc/oracle/graph/pgx.conf

EXPOSE 7007

WORKDIR /opt/oracle/graph/bin

CMD ["sh", "/opt/oracle/graph/pgx/bin/start-server"]

Build the image, replacing the JDK version with the proper version number if necessary.

docker build . \
-f Dockerfile-graph-server \
--tag graph-server:23.1.0 \
--build-arg VERSION_OPG=23.1.0 \
--build-arg VERSION_JDK=11.0.17 \
--build-arg JDBC_URL=jdbc:oracle:thin:@host.docker.internal:1521/xepdb1

Once the image is built, create a container.

docker run \
--name graph-server \
--publish 7007:7007 \
--env JAVA_TOOL_OPTIONS="-Xms1G -Xmx2G" \
--detach \
graph-server:23.1.0

Check if you can log in to the Graph Server as GRAPHUSER (= a database user created in Step 1) using opg4j shell.

$ docker exec -it graph-server opg4j -b https://localhost:7007
...
username: graphuser
password: (Welcome1)
For an introduction type: /help intro
Oracle Graph Server Shell 23.1.0
Variables instance, session, and analyst ready to use.
opg4j>
opg4j> /exit

If you need to change the JDBC URL afterward, connect to the container from a new console and edit the JDBC URL inside of pgx.conf. Then, go back to the host and restart the Graph Server container.

$ docker exec -it graph-server /bin/bash
# vi /etc/oracle/graph/pgx.conf

"jdbc_url": "jdbc:oracle:thin:@host.docker.internal:1521/xepdb1",

# exit
$ docker restart graph-server
$ docker logs -f graph-server

Log in to Graph Viz

Now you can log in to Graph Visualization from your web browser.

You will see a security warning because of the self-signed certificate. So you have to proceed with:

  • Chrome: Type “thisisunsafe” on the screen
  • Firefox: Advanced > Accept the risk and continue

Log in as the database user you created before.

- User: graphuser
- Password: Welcome1 (if you set it as described in Part1)
- Advanced Options:
- Database
- jdbc:oracle:thin:@host.docker.internal:1521/xepdb1

To visualize the graph GRAPH1 created in the previous article, execute the following PGQL query.

SELECT v1.name, v2.brand, e.since
FROM MATCH (v1)-[e]->(v2)
LIMIT 100

You can right-click on a node or edge to see its property values.

We have now created an environment for Oracle Graph. Let’s use this environment to discuss various use cases of graph databases, which I will cover in future articles.

Please learn more about Oracle Graph from:

You can also learn more by asking questions of real live developers in our public Slack channel!

--

--