简体   繁体   中英

Mount docker volume subfolders

I have a docker image that requires lots of data. This data is on different physical drives but symlinks are used to make it look like it's all on a single drive. So physically on the host machine there is a drive structure as follows:

/Data
/Data1
/Data2
/DataN

Logically I use symlinks to move various pieces of /Data1/subfolder1 into /Data/subfolder1. So in /Data there is a symlink to /Data1/subfolder1 and similar symlinks for /Data2 ... /DataN.

It seems that just mounting the /Data volume doesn't give the docker container access to the /Data2 ... /DataN physical drives via the symlink.

docker run -v /Data:/Data:ro

So I tried manually mapping each of the symlinks in the docker run command:

docker run -v /Data:/Data:ro -v /Data1/subfolder1:/Data/subfolder1

This didn't seem to work either. Is what I'm trying to achieve possible with docker? Maybe they need to be mounted in a different configuration to prevent overlapping folders?

I'm running Ubuntu 14.04 and the application running inside the docker image is a mono 4.0.5.1 application. Docker version is 1.9.1.

Instead of using symlinks to achieve the desired folder structure, you can mount the drive where they're needed. This can be accomplished using the mount -o bind or also by editing the /etc/fstab file.

Using mount :

mount -o bind /Data1/subfolder1 /Data/subfolder1

Using /etc/fstab :

/Data1/subfolder1 /Data/subfolder1 none bind 0 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM