Reputation: 4510
I'm trying to make oracle connections from my Alpine Linux container using cx_Oracle(which needs oracle instant client). cx_oracle keeps complaining about different missing libraries which are required for Oracle instant-client
Error:
con = cx_Oracle.connect('user/[email protected]/orcl') Traceback (most recent call last): File "", line 1, in
cx_Oracle.DatabaseError: 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)".
Dockerfile:
FROM alpine-base
COPY /app /base/app
COPY requirements.txt /base
COPY instantclient_12_2.zip /base
COPY instantclient_sqlplus_12_2.zip /base
COPY run_app.py /base
COPY oratest.py /base/oratest.py
WORKDIR /base
RUN apk add libaio libnsl openssl-dev musl-dev libffi-dev && \
apk add openssl-dev && \
pip install cryptography==2.2.2 && \
apk add libressl-dev && \
pip install cx_Oracle
unzip /base/instantclient_12_2.zip && \
unzip /base/instantclient_sqlplus_12_2.zip && \
mv /base/instantclient_12_2/ /usr/lib/ && \
rm -rf /base/instantclient_12_2.zip && \
ln /usr/lib/instantclient_12_2/libclntsh.so.12.1 /usr/lib/libclntsh.so && \
ln /usr/lib/instantclient_12_2/libocci.so.12.1 /usr/lib/libocci.so && \
ln /usr/lib/instantclient_12_2/libociei.so /usr/lib/libociei.so && \
ln /usr/lib/instantclient_12_2/libnnz12.so /usr/lib/libnnz12.so
ENV ORACLE_BASE /usr/lib/instantclient_12_2
ENV LD_LIBRARY_PATH /usr/lib/instantclient_12_2
ENV TNS_ADMIN /usr/lib/instantclient_12_2
ENV ORACLE_HOME /usr/lib/instantclient_12_2
RUN pip install -r /base/requirements.txt
EXPOSE 8080
CMD [ "python", "/base/run_app.py" ]
Is there anything I'm missing here? I'm pretty much done with fighting the dependencies for oracle instant client - is there a better way of making Oracle connections from alpine
I would like to see if anyone had success running cx_Oracle in alpine linux
Upvotes: 2
Views: 5018
Reputation: 10506
To repeat my earlier views:
I'd recommend using an operating system supported by Oracle, thus avoiding the headache of hacking Alpine and the uncertainty that it won't fall over at a critical time. And thus giving you some confidence your business won't be negatively impacted. Try https://github.com/oracle/docker-images/blob/master/OracleInstantClient/dockerfiles/19/Dockerfile
Upvotes: 0
Reputation: 3890
You can probably install libnsl to get past this one (https://pkgs.alpinelinux.org/package/edge/community/x86/libnsl), but—I suggest just avoiding Alpine.
All for the benefit of an only slightly smaller image (assuming need for compiler didn't make it bigger in the end).
Long version: https://pythonspeed.com/articles/base-image-python-docker-images/
Upvotes: 1