简体   繁体   English

如何将Gluster卷安装到Docker中的主机文件夹?

[英]How to mount gluster volume to host folder in docker?

I have ran my docker container like this: 我已经像这样运行了我的docker容器:

docker run -v /sys/fs/cgroup:/sys/fs/cgroup -v /opt/doc:/opt/doc \
--privileged=true --net=host -itd --name=gluster gluster-docker

then I mount a volume to a folder in container: 然后将卷安装到容器中的文件夹中:

mount -t glusterfs 192.168.1.100:/documents /opt/doc

When I write data to the /opt/doc of my real server, the data won't be rsync to the /opt/doc of the container. 当我将数据写入真实服务器的/ opt / doc时,数据将不会rsync到容器的/ opt / doc。

Is there any idea to rsync data between container and server after I have mounted the folder ? 安装完文件夹后,有什么想法可以在容器和服务器之间rsync数据吗?

gluster-docker: https://github.com/gluster/gluster-containers gluster-docker: https : //github.com/gluster/gluster-containers

Finally, I found --mount in docker-ce 17.06. 最后,我在docker -ce 17.06中找到了--mount

mount --bind /data/fff /data/fff
mount --make-shared /data/fff
docker run -v /sys/fs/cgroup:/sys/fs/cgroup -v /opt/doc:/opt/doc \
--privileged=true --net=host --mount \
type=bind,source=/data/fff,target=/data/fff,bind-propagation=rshared \
-itd --name=gluster gluster-docker

then I mount a volume to the folder in container: 然后将卷安装到容器中的文件夹:

mount -t glusterfs 192.168.1.100:/documents /data/fff

OK. 好。

https://docs.docker.com/engine/admin/volumes/bind-mounts/ https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt https://docs.docker.com/engine/admin/volumes/bind-mounts/ https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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