Database, Docker, Node.js, Oracle, oracledb

Deploy node-oracledb with Official Instant Client Image

docker node-oracledbA few days ago, I started building a PoC with the Oracle DB 12.1 and Oracle Instant Client. My goal was to deploy each component to separate and see if I could access the DB from the OIC container. Now to take it a step further. Adding the node-oracledb driver to enable Node.js interaction with the Oracle Database.

This post will pick up where I left off after having successfully connected to the Oracle DB container from the OIC container.  Let get started.

Last time, everything was already packaged up for us by Oracle in the Docker Store. This time we will be adding node-oracledb to the OIC image. Why? Because this image has all the required libraries Node needs to establish a connection to the Oracle DB. In order to add functionality to the OIC image, we will create a Dockerfile. Before we get there, we need to do a few things.


  1. Open a terminal session and create a new directory: mkdir -p nodedb
  2. Download the Node.js Linux Binaries(x64) into the directory created in step 1.
    • node-v6.11.1-linux-x64.tar.xznode-oracledb
  3. Create a file select1.js and copy and paste the following code. Save in nodedb directory

  1. Create a file Dockerfile and copy and the following code. Save in nodedb directory.

You should now have a directory with 3 files: Dockerfile, select1.js, and node-v6.11.1-linux-x64.tar.xz

Before we move on, let’s take a minute to understand what’s happening in the Dockerfile.

Line 1: downloads version of the Oracle Instant Client from the Docker Store.

Line 3: adds the node-v6.11.1-linux-x64.tar.xz file you downloaded into the nodedb directory to the instantclient image in the /opt directory

Line 4: adds the select1.js file you created in the nodedb directory into the root directory of the instantclient image

Line 5: installs some prerequisite files and does some clean up

Line 7-8: sets environment variable for PATH and the NODE_PATH

Line 9: installs oracledb driver


Deploy the Oracle database container:

Start the Database:
Connect to the container

Run the startup script

Build the Instant Client with the node-oracledb image by running the following commands from the nodedb directory.

Run the new inst_node container and connect to the Oracle DB

Connect to Oracle DB and run the select1.js script

There you have it. With the node-oracledb driver installed, we are able to query the Oracle 12.1 database through the select1.js script.

Now that you’ve taken the long way round, go visit my github repo for the files you need

EnjoydbaOnTap node-oracledb

Also published on Medium.

2 Comments on “Deploy node-oracledb with Official Instant Client Image

This site uses Akismet to reduce spam. Learn how your comment data is processed.