【问题标题】:Docker link to existing container or image at build构建时指向现有容器或映像的 Docker 链接
【发布时间】:2016-05-09 01:08:30
【问题描述】:

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

细节

我的database 图像是我已成功构建的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.

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

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

,请告诉我

【问题讨论】:

    标签: python docker pip hdf5


    【解决方案1】:

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

    FROM python:3.5
    
    RUN apt-get update
    RUN apt-get -y install libhdf5-dev
    RUN pip install tables
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-20
      • 2015-12-23
      • 2017-01-31
      • 2017-07-05
      • 2021-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多