Install Oracle Instant client into Docker container for Python cx_Oracle

后端 未结 2 1976
孤街浪徒
孤街浪徒 2020-12-16 04:08

I\'m trying to connect to an Oracle database at my company through my docker container that contains some of my python scripts with the package cx_Oracle. After i build and

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 05:07

    One solution is to try:

    FROM python:3.7.4-slim-buster
    
    RUN apt-get update && apt-get install -y libaio1 wget unzip
    
    WORKDIR /opt/oracle
    RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \
        unzip instantclient-basiclite-linuxx64.zip && rm -f instantclient-basiclite-linuxx64.zip && \
        cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *README *jar uidrvci genezi adrci && \
        echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
    RUN python -m pip install cx_Oracle
    

    If you use a different base image you may not need to explicitly install unzip or libaio1. If you're happy using ADD, then you won't need wget either.

    Also there is a recent Oracle webcast recording discussing cx_Oracle and Docker here.

    Update: A new blog post series on this is at Docker for Oracle Database Applications in Node.js and Python.

    Update 2: Oracle has Python Dockerfiles at https://github.com/oracle/docker-images/tree/master/OracleLinuxDevelopers

提交回复
热议问题