Docker 表示 Oracle Instant Client 安装成功,但探索容器的文件系统时没有“Oracle”

Docker 表示 Oracle Instant Client 安装成功,但探索容器的文件系统时没有“Oracle”

我的 docker 文件如下所示

FROM store/oracle/database-instantclient:12.2.0.1

ENV OCI_LIB=/usr/lib/oracle/12.2/client64/lib
ENV OCI_INC=/usr/include/oracle/12.2/client64
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${OCI_LIB}
ENV PATH=$PATH:/usr/lib/oracle/12.2/client64/bin

FROM rocker/rstudio
FROM rocker/tidyverse

当我运行 docker build 时,我在控制台上看到一条消息,内容如下

Step 1/15 : FROM store/oracle/database-instantclient:12.2.0.1
12.2.0.1: Pulling from store/oracle/database-instantclient
497341ef9d71: Pulling fs layer
598d27c2564a: Pulling fs layer
497341ef9d71: Verifying Checksum
497341ef9d71: Download complete
497341ef9d71: Pull complete
598d27c2564a: Verifying Checksum
598d27c2564a: Download complete
598d27c2564a: Pull complete
Digest: sha256:e83a2a223a14f24e6e433847d15d817ff7799a3a1a2dd2e4b224437358e996a0
Status: Downloaded newer image for store/oracle/database-instantclient:12.2.0.1

然而,当我探索容器的文件系统时,我在整个文件系统中根本看不到对“Oracle”的引用。

我做了以下探索

# find ID of your running container:
docker ps

# create image (snapshot) from container filesystem
docker commit 12345678904b5 mysnapshot

# explore this filesystem using bash (for example)
docker run -t -i mysnapshot /bin/bash

这是怎么回事..??

答案1

据我所知,FROMDockerfile 中的后续行 ( FROM rocker/rstudio...) 会清除已完成的操作。最终容器映像是从最后一个 FROM 开始构建的。如果要从之前构建的映像中继承内容,则必须明确将它们 COPY 到当前映像中。请参阅Docker 多阶段构建文档

我不确定检索初始映像中 Oracle 所需的所有内容以将其复制过来是否可行。也许你应该:

  1. 在 Oracle 映像中安装/添加内容。
  2. 构建前两个映像,即 Oracle 映像,并将内容复制到 Oracle 映像。
  3. 有两个容器,一个装有普通的 Oracle,一个装有其他东西,这是通常的做事方式。

答案2

我得到了以下工作。

FROM oraclelinux:7-slim AS oracrap

RUN  yum -y install oracle-release-el7 && yum-config-manager --enable ol7_oracle_instantclient && \
     yum -y install oracle-instantclient18.5-basic oracle-instantclient18.5-devel oracle-instantclient18.5-sqlplus && \
     rm -rf /var/cache/yum && \
     echo /usr/lib/oracle/18.5/client64/lib > /etc/ld.so.conf.d/oracle-instantclient18.5.conf && \
     ldconfig

ENV PATH=$PATH:/usr/lib/oracle/18.5/client64/bin       


FROM rocker/rstudio:3.5.0

COPY --from=oracrap /usr/lib/oracle /usr/lib/oracle/
COPY --from=oracrap /usr/include/oracle /usr/include/oracle/
ENV PATH=$PATH:/usr/lib/oracle/18.5/client64/bin:/usr/lib/oracle/18.5/client64/lib:/usr/include/oracle/18.5/client64/
ENV OCI_LIB=/usr/lib/oracle/18.5/client64/lib
ENV OCI_INC=/usr/include/oracle/18.5/client64
ENV ORACLE_HOME=/usr/lib/oracle/18.5/client64
ENV LD_LIBRARY_PATH=/usr/lib/oracle/18.5/client64/lib
ENV LD_LIBRARY_PATH_64=/usr/lib/oracle/18.5/client64/lib

RUN ln -s /usr/lib/oracle/18.5/client64/lib/libclntsh.so.18.1   libclntsh.so.18.1

FROM rocker/tidyverse:3.5.0

COPY --from=oracrap /usr/lib/oracle /usr/lib/oracle/
COPY --from=oracrap /usr/include/oracle /usr/include/oracle/
ENV PATH=$PATH:/usr/lib/oracle/18.5/client64/bin:/usr/lib/oracle/18.5/client64/lib:/usr/include/oracle/18.5/client64/
ENV OCI_LIB=/usr/lib/oracle/18.5/client64/lib
ENV OCI_INC=/usr/include/oracle/18.5/client64
ENV ORACLE_HOME=/usr/lib/oracle/18.5/client64
ENV LD_LIBRARY_PATH=/usr/lib/oracle/18.5/client64/lib
ENV LD_LIBRARY_PATH_64=/usr/lib/oracle/18.5/client64/lib

RUN ln -s /usr/lib/oracle/18.5/client64/lib/libclntsh.so.18.1  libclntsh.so.18.1

相关内容