Docker链接到构build的现有容器或图像

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

细节

我的database映像是我已经成功构build的HDF5数据存储。

我的app图像是一个Python 3.5映像,它安装了用于处理HDF5包。 我正在build立的错误是:

 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. 

我想我需要创build一个HDF5_DIR环境variables在我的app Dockerfile使用类似ENV HDF5_DIR path/to/hdf5/container/urs/bin/ld但我不知道如果这是正确的或如何获得正在运行的database的path容器。 或者,如果将其链接到database容器是不正确的,我需要链接到实际的图像(如果这是可能的)。

我知道HDF5不是一个常用的工具,但希望这是一个通用的解决scheme更通用的问题。 让我知道你是否需要看到完整的Dockerfile

您需要将libhdf5-dev添加到您的泊坞窗图像。 我创build了一个可以扩展的Dockerfile:

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