Docker Community Forums

Share and learn in the Docker community.

System Docker Not Mounting Recursively


(Lijax) #1

I’m working with containers on RancherOS, and using system-docker for managing the containers. I’m attempting to create a new container and mount various volumes from the host onto the container. Unfortunately -v seems to only add the directory specified, not the files and directories inside it. I imagine this is not the intention as I’ve done this on a different distro and using regular docker and the volume mounting recursively adds the content of the directory specified.

Hopefully someone has encountered this problem before or someone has any insight on solving it.
Thank you


(Brandon Mitchell) #2

Typically this means you haven’t mounted the host folder you intended. If you are running through docker-machine it is likely mounting folders from your VM. You also need to specify the full path to a host mount with the docker run command, not a relative folder like you can in docker-compose. You also need to be careful with uid’s between a host and container since files owned by a user on the host may need to be chown’d inside the container to access.


(Lijax) #3

So I’m running my container inside a rancheros vm. Going through all the suggestions you gave, I’m not sure what you mean by not mounting the host folder you intended. I am specifying the full path in the docker command so I know that is not the issue. I also tried making my current user the owner of the directory I’m trying to mount, but that also didn’t seem to work. So the only suggestion I didn’t seem to try was the first one, but I’m not entirely sure what you’re saying. Is it possible you could explain it slightly more in depth. Thank you so much for the assistance and sorry for the trouble.


(Lijax) #4

To be more specific, I am inside a system-docker container inside a rancheros vm. I am trying to build another container and mount volumes from the current container I sit inside to the new one. Here is the command I’m running to create the new container.
sudo system-docker run --privileged -d -e “HOSTNAME=test” --net host --uts host --ipc host -p 80:80 -v /usr/lib/python2.7/:/usr/lib/python2.7/ --name=test lijax/ubuntu-dev /sbin/init

I’ve also tried mounting the sub-directories exactly but that doesn’t work either. Such as
sudo system-docker run --privileged -d -e “HOSTNAME=test” --net host --uts host --ipc host -p 80:80 -v /usr/lib/python2.7/test/:/usr/lib/python2.7/test/ --name=test lijax/ubuntu-dev /sbin/init

Inside python2.7 on the host are both directories and files. python2.7 in the newly created container is empty.


(Brandon Mitchell) #5

Containers inside of containers gets outside of my specialty. My suspicion is that you are trying to mount a directory that’s on the bare metal OS, rather than placing the directory inside of RancherOS. And since docker is running inside of that VM, it doesn’t have visibility to the filesystems outside of RancherOS.


(Lijax) #6

While I understand where you’re coming, a week ago I was doing the same thing where the volumes were mounted properly. Now, they are not and the only difference is before I had a vagrantfile build the vm, now I am building it from network. I suppose that implies that the vm itself is the problem, but aside from the way I build it, they work exactly the same, sans the volume mounting of course.