Docker Community Forums

Share and learn in the Docker community.

Error using Oracle Instance Client Docker image - libnsl.so.1 not found

Hi, our app is nodes based and needs to query Oracle DB, so we install NPM oracledb package. So our Docker image is based on oracle instant client (https://hub.docker.com/r/asg1612/alpine-oracle-instantclient), the Docker file looks like following:

FROM frolvlad/alpine-glibc

RUN apk update && apk add libaio

COPY instantclient_12_1.zip ./
RUN unzip instantclient_12_1.zip && \
mv instantclient_12_1/ /usr/lib/ && \
rm instantclient_12_1.zip && \
ln /usr/lib/instantclient_12_1/libclntsh.so.12.1 /usr/lib/libclntsh.so && \
ln /usr/lib/instantclient_12_1/libocci.so.12.1 /usr/lib/libocci.so && \
ln /usr/lib/instantclient_12_1/libociei.so /usr/lib/libociei.so && \
ln /usr/lib/instantclient_12_1/libnnz12.so /usr/lib/libnnz12.so

ENV ORACLE_BASE /usr/lib/instantclient_12_1
ENV LD_LIBRARY_PATH /usr/lib/instantclient_12_1
ENV TNS_ADMIN /usr/lib/instantclient_12_1
ENV ORACLE_HOME /usr/lib/instantclient_12_1

#install node js
RUN apk add nodejs npm

#install our App
RUN mkdir -p /var/app
WORKDIR /var/app
ADD package.json /var/app
COPY . /var/app

#Now start node
CMD [“npm”,“start”]

But when our app starts using ‘oracledb’ NPM package, it got following error:

**init() error: DPI-1047: Cannot locate a 64-bit Oracle Client library: “Error loading shared library libnsl.so.1: No such file or directory (needed by /usr/lib/libclntsh.so)”. …

So Oracle client couldn’t find libnsl.so.1 even thought it should come with glibc, and I can see that it is under:
‘/usr/glibc-compat/lib’.
Any ideas how to fix this? Thanks in Advance.

-Andy

You have to add this to your Dockerfile:

RUN echo “http://dl-cdn.alpinelinux.org/alpine/edge/community” >> /etc/apk/repositories &&
apk add --update libaio libnsl &&
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1

and then add the packages libc6-compat and gcompat

is this procedure safe?