Docker Community Forums

Share and learn in the Docker community.

Linking container during build


(Joost Den Boer) #1

Hi,

I created a Dockerfile to construct a container for a web application that relies on Mongo.
For Mongo I want to use a seperate Mongo container.
Is there a way to link to the Mongo container when building the app container? Otherwise it is not possible to add a ‘RUN’ statement which automatically starts the web app when the container is build. I want to rely on the environment settings set when linking to another container, but those settings are not available when the other container is not linked.

Joost


(Sven Dowideit) #2

mmm, first up, you can’t link to another container at build time.

But I’m not sure you want RUN to start the web app at build time, as it will get stopped at the end of that RUN. If you want the web app to be started when you docker run it, you need either CMD or ENTRYPOINT - see http://docs.docker.com/reference/builder/#cmd