The leading edge of scripting languages and Oracle Database brought to you by the Data Access Development team

Dockerfiles for node-oracledb are Easy and Simple

Christopher Jones
Senior Principal Product Manager

Things change fast and it's time for an update on running Node.js in Docker. Let's dive right in. Here's a Dockerfile that pulls the lightweight Oracle Linux "slim" image, installs the latest Node.js runtime, and installs the Oracle Client libraries needed for the node-oracledb module. Note no Docker store login or manual downloads are required:

FROM oraclelinux:7-slim

RUN  yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
     yum-config-manager --disable ol7_developer_EPEL && \
     yum -y install oracle-instantclient19.3-basiclite nodejs && \
     rm -rf /var/cache/yum

WORKDIR /myapp
ADD package.json /myapp/
ADD index.js /myapp/
RUN npm install

CMD exec node index.js

If you have Oracle Net configuration files such as a tnsnames.ora file, or wallet files, you can add an extra COPY after installing Instant Client to move the files to the default Oracle location, for example:

COPY wallet/* /usr/lib/oracle/19.3/client64/lib/network/admin/

(Beware this will mean the wallet is embedded in the image - you may want to mount the wallet using a volume instead)

Put your package.json and application index.js in the directory with your Dockerfile. The package.json file should include the node-oracledb module as a normal dependency:

  "name": "cjtest",
  "version": "1.0.0",
  "private": true,
  "description": "Test application",
  "scripts": {
    "start": "node index.js"
  "keywords": [
  "dependencies": {
    "oracledb" : "^3.1"
  "author": "CJ",
  "license": "MIT"

The app index.js is, for the sake of a quick demonstration, a very simple app:

const oracledb = require('oracledb');

Then build your image:

sudo docker build --pull -t cjn .

This installs all required dependencies, which, in this example is just the node-oracledb module.

Now you can run it:

sudo docker run cjn

The output is the expected node-oracledb version number:


There you go. No mess, no fuss. You have deployed Node.js in a Docker container on a supported operating system with a simple, clean Dockerfile setup.

One final tip: If you want to install other Instant Client packages check the Instant Client 19c Dockerfile.

Update #1: if you are using your own containers to deploy in Oracle Functions, don't forget to add this to your Dockerfile otherwise database connections will fail with 'ORA-12560: TNS:protocol adapter error':

groupadd --gid 1000 fn && \
adduser --uid 1000 --gid fn fn

See Permissions Granted to Containers Running Functions.

Update #2: For lots of detail, check out Blaine Carter's post How To Connect Your Node.js App In Docker To Your Oracle Database.

Update #3: if you prefer using Node.js images, then you can try a Dockerfile something like:

FROM node:12.9.1-buster-slim

RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y alien libaio1
RUN wget https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.3-basiclite-
RUN alien -i --scripts oracle-instantclient*.rpm
RUN rm -f oracle-instantclient19.3*.rpm && apt-get -y autoremove && apt-get -y clean

WORKDIR /myapp
ADD package.json /myapp/
ADD index.js /myapp/
RUN npm install

CMD exec node index.js

Update #4: if you liked this post, also check out the newer posts Docker for Oracle Database Applications in Node.js and Python.

Join the discussion

Comments ( 4 )
  • Nexon Thursday, July 11, 2019
    I'm running into this "Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory". Does anyone else get this?
  • Christopher Jones Thursday, July 11, 2019
    At a wild guess, are you trying this on Alpine Linux? If so, see my comments on Alpine such as https://stackoverflow.com/a/53291026/4799035

    In general the best place to ask for tech help on the Dockerfiles is https://github.com/oracle/docker-images/issues
  • Nexon Friday, July 12, 2019
    Thanks for the reply Christopher; I figured it out. It was a conflict with another npm package(hummus-recipe).
  • Roberto Robson Soares Nogueira Saturday, April 25, 2020
    Ok I got that we need use the Oracle Linux Image, but how hard is to give us a slim image. So far just for a Hello World My image start from 340Mb, it looks like there is a way to run something like a cleanup there.

    What is your thoughts Christopher?
    It is possible?

    I made a docker image comparison here
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.