Search code examples
oracledockerapache-superset

Unable to use amancevice/superset docker image to use Oracle DB as datasource


I'm trying to test if superset would be adecuate for our data visualization needs. As I've no knowledge of python, I'm using a docker image of a superset installation (v0.37.1) published with all the libraries needed to connect to different databases (https://github.com/amancevice/docker-superset). When I try to set up a new database source to an Oracle database I get this error in the superset.log:

Unexpected error (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
(Background on this error at: http://sqlalche.me/e/13/4xp6)

After googling I've added to the container (when I have this solved I'll investigate how to create a new image with all the changes I've performed directly to the container) the Oracle Instant Client library and modified the .bashrc file of the container (for the user superset) to add a new env variable LD_LIBRARY_PATH pointing to the directory with the Oracle Instant Client. I've restarted the container. To check that SQLAlchemy can connect to my OracleDB correctly I've created a test_script.py:

import sqlalchemy as sa
engine = sa.create_engine('oracle+cx_oracle://user:password@host:port/?service_name=service')
with engine.connect() as connection:
    result = connection.execute("select * from dual")
    for row in result:
        print(row)

And then if I connect to the container directly docker exec -it my_container bash and execute my script python test_script.py, I get the correct results and no error message, however, connecting to the superset url and trying to create a new datasource to that Oracle DB, I'm still getting the same error.

Does someone know if there's another configuration change needed in the container to make this work?


Solution

  • When you download Oracle Instant Client Basic or Basic Light ZIP packages from here, then run something like this in your Dockerfile:

    RUN echo /opt/oracle/instantclient_19_8 > /etc/ld.so.conf.d/oic.conf && \
        ldconfig
    

    Also see sample docker images for Linux developers and for basic Oracle Instant Client. If you are not on an RPM based system, check out the sample Docker files in Docker for Oracle Database Applications in Node.js and Python.

    The details vary with what base Docker image you are using, and whether you want to install Instant Client from ZIP files or RPMs.

    Update: prebuilt containers are available from Oracle's GitHub Container Registry.