I needed to connect to an Oracle database from a Python app and wrote a Dockerfile to put in a Python client, but I had a hard time so I'll write it as a memorandum.
Dockerfile
FROM python:3.7
RUN pip install cx_Oracle
# Install Oracle Client
ENV ORACLE_HOME=/opt/oracle
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
RUN apt-get update && apt-get install -y libaio1 && rm -rf /var/lib/apt/lists/* \
&& wget -q https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip \
&& unzip instantclient-*.zip \
&& mkdir -p $ORACLE_HOME \
&& mv instantclient_19_6 $ORACLE_HOME/lib \
&& rm -f instantclient-*.zip
cx_Oracle 8 Initialization — cx_Oracle 8.0.0 documentation
According to the official documentation, the Oracle Client library must be installed in order to use cx_Oracle, and cx_Oracle will try to load the library in the following order:
cx_Oracle.init_oracle_client (lib_dir =" ... ")
$ LD_LIBRARY_PATH
)$ORACLE_HOME/lib
Of these, when I tried using the methods 1.
and 3.
, I was very troubled because I got an error saying "There is no such file" only for libnnz19.so
even though other libraries can be read.
The cause is still unknown.
I tried the 2.
method and it loaded without any problems.
Recommended Posts