Docker Community Forums

Share and learn in the Docker community.

Way to mount some data from other container in dockerfile

Is there a way in dockerfile how can I mount data from other container some equivalent of --volumes-from ?

No. What’s your end goal?

My planned use case is to have nginx container that will utilize some other container which will hold data. It should server as some shared folder, but I don’t want to specify it on command line. I would like to have something like:

  1. docker run nginx (internally reference app-container)
  2. docker run (or just create) app-container:1.0(with dockerfile specified VOLUME)

to update

  1. docker stop nginx
  2. docker run( or just create) app-container:1.1
  3. dockre run nginx

You cannot specify, at build time, what other containers or host content must exist: an image is supposed to be independent of its surrounding ecosystem. If you find yourself frequently wanting to start collections of containers with common settings, using Docker Compose and writing a docker-compose.yml file that describes it is probably a good path.

I has been thinking about compose. The problem I see, is that you need always to start whole compose file at once. Imagine I will grow further, I will create another container with tomcat behind mentioned nginx. And then I want to be able to manage the tomcat container separately.

So it look like there is no way how to access common shared folder from multiple containers right? I.e. mount the same host folder in all containers.