[ Docker link to existing container or image at build ]
I am trying to separate an app into an app
image and a database
image using 2 Dockerfiles
. Both are using FROM debian:jessie
as a base image. The issue that I am running into is that certain packages in the app
image need to know the database location at build. Is there any way to link a build command to an existing image or container?
Specifics
My database
image is an HDF5 datastore which I have successfully built.
My app
image is a Python 3.5
image which installs packages for working with HDF5
. The error that I am getting at build is:
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.
I think I need create an HDF5_DIR
environment variable in my app
Dockerfile
using something like ENV HDF5_DIR path/to/hdf5/container/urs/bin/ld
but I am not sure if that is correct or how to get the path to a running database
container. Or if linking it to the database
container is incorrect and I need to link it to the actual image (if that's even possible).
I know that HDF5
is not a common tool, but hopefully this is more of a generic issue with a generic solution. Let me know if you need to see the full Dockerfile
s
Answer 1
You need to add libhdf5-dev to your docker image. I create a Dockerfile you can extend:
FROM python:3.5
RUN apt-get update
RUN apt-get -y install libhdf5-dev
RUN pip install tables