Docker Community Forums

Share and learn in the Docker community.

How to manage $PATH and executables when using several images?


(Rioualen) #1

Hello,
I’m building several images corresponding to a list of programs, and an image that use all of them. The thing is, I don’t get how to access the programs from the latter. An example will be easier to understand, say I have this image:

FROM ubuntu:14.04

RUN apt-get -y install python3-pip python3.4-dev
RUN pip3 install snakemake

Now when I run this image, the command “snakemake” works just fine.

Now I have this second image:

FROM ubuntu:14.04
FROM my/python:1.0

When I run this image, I can’t execute the “snakemake” command. I have the same issue with other programs for which I manually update the $PATH or manipulate executable files, so I’m looking for a general solution on how to handle these issues.

I know this may be trivial, but I’m new to Docker and I don’t understand all of the concepts yet.

Thank you !

My configuration:
Linux Mint Debian Edition
Docker version 1.9.1, build a34a1d5


(David Maze) #2

A Docker image has only one parent image; you can’t “blend” images the way you’re suggesting. (What if, for instance, the my/python:1.0 image was actually based on Alpine, which has a different libc?)

If you need access to multiple commands in a later image, you need to install them all in the earlier image (or the single image).

If you have multiple independent parts that need to communicate, the usual way to connect things together is with network access, either using a private network or using the docker run --link option.

Each FROM line in the Dockerfile actually starts a new image, so the sample you show above actually creates two images. If you look at the docker images output in detail you will probably see the tag you specified on docker build has the same hex ID as the ubuntu:14.04 image.