[PYTHON] Docker image that can use cx_Oracle

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:

  1. The path specified by cx_Oracle.init_oracle_client (lib_dir =" ... ")
  2. OS library path ($ LD_LIBRARY_PATH)
  3. $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

Docker image that can use cx_Oracle
Build a Docker environment that can use PyTorch and JupyterLab
Use cryptography library cryptography with Docker Python image
Skflow that can use TensorFlow like scikit-learn
I made a Docker image that can call FBX SDK Python from Node.js
Expose your Docker image
ANTs image registration that can be used in 5 minutes
Use python with docker
Jupyter Docker image summary
Use cases that motivate you to use Docker that you have never used
Try using Jupyter's Docker image