简体   繁体   English

将docker卷与NFS分区一起使用

[英]Using docker volume with a NFS partition

I have a NFS partition on the host, if add it to a container with 我在主机上有一个NFS分区,如果将其添加到容器中

docker run -i -t -v /srv/nfs4/dir:/mnt ubuntu

/mnt will contain the shared data, but doesn't it cause conflicts? / mnt将包含共享数据,但是它不会导致冲突吗? Since it hasn't been mounted with nfs-client? 既然没有用nfs-client挂载?

Docker uses bind mounts to share host directories with containers. Docker 使用绑定挂载与容器共享主机目录。 Docker handles namespace permission so that the container can access the mount. Docker处理名称空间权限,以便容器可以访问装载。 Otherwise from the host's perspective, the bind mounted NFS share is just being accessed by another process. 否则,从主机的角度来看,绑定挂载的NFS共享只是被另一个进程访问。 It's safe to bind mount an NFS share elsewhere on the filesystem. 将NFS共享挂载到文件系统的其他位置是安全的。 Using it from within a Docker container is no different. 在Docker容器中使用它没有什么不同。

As of Docker 1.7+ you can use a Volume Plugin. 从Docker 1.7+开始,您可以使用Volume Plugin。 See the Docker Volume Plugin section for details. 有关详细信息,请参阅Docker Volume Plugin部分。

As far as NFS goes you can use the Docker Netshare plugin which handles mounding NFS, CIFS and AWS EFS file systems. 就NFS而言,您可以使用Docker Netshare插件来处理群集的NFS,CIFS和AWS EFS文件系统。

You have to share /srv/nfs4/ in your default docker machine. 您必须在默认的docker机器中共享/ srv / nfs4 /。 Go to virtualbox > default (or boot2docker) > settings > Shared Folder 转到virtualbox> default(或boot2docker)>设置>共享文件夹

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

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