Reverse mount from Docker container?

Hey everyone,

Is it possible to reverse mount a directory from a Docker container? I.e we can mount a directory FROM our host to a docker container, but can we do the reverse without using SAMBA or something similar?

I am using Boot2Docker for OSX

The docker run -v /host/path:/container/path notation does this. It will set up a bind mount so that changes in the host get persisted in the container and vice versa.

You can also do something like https://registry.hub.docker.com/u/svendowideit/samba/ to export a Docker volume using samba (or using any other server)

Hi I also come up with this requirement.
The solution of using samba etc is good enough but it again breaks the idea of having only a single process per container doesn’t it?

Currently I have this requirement within my development workflow. I’m a Java Webapp developer.
I have a docker container where tomcat is running. I’m using Eclipse as my IDE. Within eclipse you can define your tomcat server so you can deploy, debug, check logs directly within the IDE. Therefore I have to configure eclipse to point to the the tomcat root directory.

So I would like to do a reverse mount. basically -v --reverse /directory-of-container /directory-of-host

Let’s say my tomcat is installed within the container in /opt/tomcat and I wanted to point that to /home/user/tomcat I would like to do something like

-v --reverse /opt/tomcat:/home/user/tomcat

Now I could configure my IDE to use this tomcat.

1 Like

The samba container I mention above runs as a separate container - so no, it is inline with the one process per container.

in fact, it encourages you to have a volume container too :smile:

so for your example, you’d run tomcat in a container, in which you’ve made the /opt/tomcat dir a VOLUME, and then you’d run the svendowideit/samba container with that tomcat container (or your common data volume container) namd as its parameter, and then use the cifs network mount facility on your OSX / Windows / Linux host to mount that share into /home/user/tomcat.

I don’t have time to continue to implement that in b2d right now, but its still on my list :slight_smile:

Nice thank you for the clarification. I’ll try that as soon as I can.
But as far as I understand the VOLUME command that would give me a complete empty folder within my container right?

I mean I have a container with tomcat installed which is in /opt/tomcat
so their are subfolders like

  • conf
  • bin
  • webapps

If I now do a VOLUME then the folder is mapped to a folder within my host which means it would be empty…