简体   繁体   English

Oracle Instant 客户端的 Alpine 依赖地狱

[英]Alpine dependency hell with Oracle Instant client

I'm trying to make oracle connections from my Alpine Linux container using cx_Oracle(which needs oracle instant client).我正在尝试使用 cx_Oracle(需要 oracle 即时客户端)从我的 Alpine Linux 容器建立 oracle 连接。 cx_oracle keeps complaining about different missing libraries which are required for Oracle instant-client cx_oracle 不断抱怨缺少 Oracle 即时客户端所需的不同库

Error:错误:

con = cx_Oracle.connect('user/pass@127.0.0.1/orcl') Traceback (most recent call last): File "", line 1, in con = cx_Oracle.connect('user/pass@127.0.0.1/orcl') 回溯(最近一次调用最后一次):文件“”,第 1 行,在

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)". cx_Oracle.DatabaseError:DPI-1047:找不到 64 位 Oracle 客户端库:“加载共享库 libnsl.so.1 时出错:没有这样的文件或目录(/usr/lib/libclntsh.so 需要)”。

Dockerfile: 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我几乎已经完成了与 oracle 即时客户端的依赖关系的斗争 - 有没有更好的方法可以从 alpine 建立 Oracle 连接

I would like to see if anyone had success running cx_Oracle in alpine linux我想看看是否有人在 alpine linux 中成功运行 cx_Oracle

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.您可能可以安装 libnsl 来解决这个问题( https://pkgs.alpinelinux.org/package/edge/community/x86/libnsl ),但是 - 我建议避免使用 Alpine。

  1. You don't get binary wheels, so you have to compile packages yourself, which makes things harder and your images bigger.你没有二进制轮子,所以你必须自己编译包,这会让事情变得更难,你的图像更大。
  2. The C library is different enough that some things occasionally break. C 库非常不同,有些东西偶尔会中断。

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/长版: https : //pythonspeed.com/articles/base-image-python-docker-images/

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.我建议使用 Oracle 支持的操作系统,从而避免黑客入侵 Alpine 的头痛以及它不会在关键时刻崩溃的不确定性。 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试试https://github.com/oracle/docker-images/blob/master/OracleInstantClient/dockerfiles/19/Dockerfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM