python - Docker 在构建时链接到现有容器或镜像

标签 python docker pip hdf5

我正在尝试使用 2 个 Dockerfiles 将应用程序分为 app 镜像和 database 镜像。两者都使用 FROM debian:jessie 作为基础镜像。我遇到的问题是 app 镜像中的某些包需要知道构建时的数据库位置。有什么方法可以将构建命令链接到现有镜像或容器吗?

具体

我的数据库图像是HDF5我已成功构建的数据存储。

我的 app 镜像是一个 Python 3.5 镜像,它安装用于使用 HDF5 的软件包。我在构建时遇到的错误是:

Step 15 : RUN pip install tables
 ---> Running in 9ea6d6b53a19
Collecting tables
  Downloading tables-3.2.2.tar.gz (7.0MB)
    Complete output from command python setup.py egg_info:
    /usr/bin/ld: cannot find -lhdf5
    collect2: error: ld returned 1 exit status
    * Using Python 3.5.1 (default, Jan 13 2016, 18:51:24)
    * USE_PKGCONFIG: True
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.

我认为我需要使用 ENV HDF5_DIR path/to/hdf5 之类的内容在我的 app Dockerfile 中创建一个 HDF5_DIR 环境变量/container/urs/bin/ld 但我不确定这是否正确或如何获取正在运行的database 容器的路径。或者,如果将其链接到数据库容器不正确,我需要将其链接到实际图像(如果可能的话)。

我知道 HDF5 不是一个通用工具,但希望这更多是通用解决方案的通用问题。如果您需要查看完整的 Dockerfiles

,请告诉我

最佳答案

您需要将 libhdf5-dev 添加到您的 docker 镜像中。我创建了一个您可以扩展的 Dockerfile:

FROM python:3.5

RUN apt-get update
RUN apt-get -y install libhdf5-dev
RUN pip install tables

关于python - Docker 在构建时链接到现有容器或镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35116020/

相关文章:

docker - 如何将Docker容器添加到正在运行的kubernetes容器中?

linux - 在 Docker 中使用 Docker 的父 Docker 容器

Python - 'MSVCCompiler' 对象没有属性 'compiler'

python - 如何在 Pandas 中加载sframe格式文件?

python - Pandas.apply 返回随机子字符串

azure - 文件不在 docker workdir azure web 应用程序中

python - sudo pip : why, 为什么不和替代品

python - 如何使用 Pip 18.1 安装特定的 pip 版本?

python - 如何实现自定义迭代器以便可以嵌套它们?

python - 一次熔化和过滤 Pandas 数据框