Exposing mounts within Containers

Is it possible to perform an nfs or cifs mount within a container and access the mounted filesystem from the host and/or other containers?

In my testing with 1.7.0 and 1.8.0-dev the mount within the container is not reflected in the /var/lib/docker/volumes filesystem. For test purposes the host os is Ubuntu 15.04, the guest os is Ubuntu 14.04, selinux is not installed and apparmor is disabled.

Ultimately I am hoping to use the nfs volume-plugin to allow mounting of external nfs volumes in a container using the --volume-drive=nfs and -v nfs-share:mount format. This works fine if the plugin app is running on the host and thus the nfs mounts happen on the host, but does not work when the plugin app is running in a container. The mount is visible in the container and the path is created in /var/lib/docker/volumes, but the share contents are not visible.

Thanks for any information,

Seoras.

Something like https://github.com/SvenDowideit/docker-volumes-nfs ?

I’m working on this too, to give us some options to improve the way
Boot2Docker accesses your files.

Sven

Docker Engineer
Ask me anything …
Brisbane, Australia (UTC+10)

1 Like

Hi Sven,

I am actually using your plugin right now, so many thanks for taking the time to put it together! Do you know if it is or will be possible to expose mounts made within Containers to the host and/or other Containers via normal docker Volumes?

Seoras.

Hi Seoras,

In order to mount to host within the container, ‘–privileged’ and nsenter are needed.

Here is a good article. http://michaelneale.blogspot.com/2015/02/mounting-devices-host-from-super.html

Hi Sven,

Were you able to ever do that - mounting a CIFS share inside a container and exposing it to other containers as a volume?

I was able to make it work on docker 17.06:

docker run --mount 'type=volume,src=src_name,volume-driver=local,dst=/mnt,volume-opt=type=nfs,volume-opt=device=:/nfs-share,"volume-opt=o=nfs-server,vers=4,hard,timeo=600,rsize=1048576,wsize=1048576,retrans=2"' -d -it --name mycontainer ubuntu

Got the hint from