gpt4 book ai didi

linux - 使用 Oracle Instant Client Docker 镜像时出错

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:14:09 29 4
gpt4 key购买 nike

我们的应用是基于 nodejs 的,需要查询 Oracle DB,所以我们安装了 NPM oracledb 包。所以我们的Docker镜像是基于 oracle instant client的,Docker 文件如下所示:

FROM frolvlad/alpine-glibc

RUN apk update && apk add libaio

COPY instantclient_12_1.zip ./
RUN unzip instantclient_12_1.zip
RUN mv instantclient_12_1/ /usr/lib/
RUN rm instantclient_12_1.zip
RUN ln /usr/lib/instantclient_12_1/libclntsh.so.12.1 /usr/lib/libclntsh.so
RUN ln /usr/lib/instantclient_12_1/libocci.so.12.1 /usr/lib/libocci.so
RUN ln /usr/lib/instantclient_12_1/libociei.so /usr/lib/libociei.so
RUN ln /usr/lib/instantclient_12_1/libnnz12.so /usr/lib/libnnz12.so

ENV ORACLE_BASE /usr/lib/instantclient_12_1
ENV LD_LIBRARY_PATH /usr/lib/instantclient_12_1
ENV TNS_ADMIN /usr/lib/instantclient_12_1
ENV ORACLE_HOME /usr/lib/instantclient_12_1

RUN apk add nodejs npm

RUN mkdir -p /var/app
WORKDIR /var/app
ADD package.json /var/app
COPY . /var/app

CMD ["npm","start"]

但是当我们的应用程序开始使用“oracledb”NPM 包时,出现以下错误:

init() error: 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)". See https://oracle.github.io/odpi/doc/installation.html#linux for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

所以 Oracle 客户端找不到 libnsl.so.1 甚至认为它应该与 glibc 一起提供,我可以看到它位于:'/usr/glibc-compat/lib'.任何想法如何解决这一问题?提前致谢。

最佳答案

# 1. Install dependencies
FROM node:8.15 as cache-package

COPY package.json /srv/src/package.json
WORKDIR /srv/src

RUN yarn install

# 2.
FROM node:8.15 as builder

# 1. Update everything on the box
RUN apt-get update && \
apt-get install sudo
#RUN apk --update add libaio bc net-tools
RUN sudo apt-get install unzip
RUN sudo apt-get install wget
RUN sudo apt-get install git

# 3. Install oracle client
RUN mkdir -p /opt/oracle
# 3.1 Get oracle client
WORKDIR /opt/oracle

RUN wget -O /opt/oracle/instantclient_18_3_linux.zip http://YOUR_URL_TO_DOWNLOAD_THE_CLIENT/instantclient_18_3_linux.zip
RUN sudo unzip /opt/oracle/instantclient_18_3_linux.zip

# 3.2 Configure oracle client to work with node
RUN sudo sh -c "echo /opt/oracle/instantclient_18_3_linux > /etc/ld.so.conf.d/oracle-instantclient.conf"
RUN sudo cat /etc/ld.so.conf.d/oracle-instantclient.conf



FROM node:8.15

RUN apt-get update && \
apt-get install sudo
RUN sudo apt-get install libaio1

RUN mkdir -p /srv/src/logs
RUN mkdir -p /srv/logs
RUN mkdir -p /opt/oracle

# 4. Set the working directory

# 5. Copy our project & install our dependencies
COPY --from=cache-package /srv/src /srv/src

COPY --from=builder /opt/oracle/instantclient_18_3_linux /opt/oracle/instantclient_18_3_linux
COPY --from=builder /etc/ld.so.conf.d/oracle-instantclient.conf /etc/ld.so.conf.d/oracle-instantclient.conf

RUN sudo ldconfig

RUN ln -sf /usr/share/zoneinfo/WET /etc/localtime

COPY . /srv/src

WORKDIR /srv/src

# 6. Start the app
CMD yarn start

这是我的 dockerfile,工作正常,srv/src 是我的目录,我的代码在其中,只需更改为您的代码,它应该可以工作。

我这两天遇到了和你一样的问题,现在好了。

关于linux - 使用 Oracle Instant Client Docker 镜像时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55852183/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com