安装path不匹配

我正在尝试在主机上挂载一个nfs文件系统,然后在安装完成后启动的docker容器上访问该挂载。 但是,由于某些原因,docker容器实际上并没有正确安装。

sudo mkdir /mnt/testlocation sudo mount -t nfs4 my-test-volume.nfs.bla.com:/ /mnt/testlocation sudo docker run -it -v /mnt/testlocation/:/testlocation/ my-test-container /bin/bash 

在运行mount命令后,在主机上运行mount命令时,可以导航到/ mnt / testlocation,并在导航到/ testlocation时没有文件的情况下,在Docker容器内查找NFS卷上的文件。 我甚至可以在Docker容器中的/ testlocation中添加文件,而且它们不会显示在NFS卷中。 然而,当我去和“umount / mnt / testlocation”,我会发现我在docker容器中修改的文件现在可以在/ mnt / testlocation主机上。

奇怪的是,我能够在一台服务器上运行一次,但我不清楚这是怎么发生的。

在周围search我发现有关共享和从属传播模式的信息,但它似乎并不是我遇到的问题,但试图使用这些传播模式照亮了一些有趣的事情,可能表明什么是错的?

在运行docker容器的服务器上可以访问nfs文件,我得到了以下输出:

 sudo docker run -v /mnt/testlocation/:/testlocation/:shared my-test-container /bin/bash docker: Error response from daemon: linux mounts: Path /mnt/testlocation is mounted on /mnt/testlocation but it is not a shared mount.. 

在运行docker容器的服务器上无法访问nfs文件,我得到了以下输出:

 sudo docker run -v /mnt/testlocation/:/testlocation/:shared my-test-container /bin/bash docker: Error response from daemon: linux mounts: Path /mnt/testlocation is mounted on / but it is not a shared mount.. 

我不确定是什么导致了这两个地方的安装位置不匹配,特别是因为如果我去看看两个服务器之间的/ etc / mtab中的条目,它们是完全一样的,并具有:

 my-test-volume.nfs.bla.com:/ /mnt/testlocation nfs4 rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.15.2.63,local_lock=none,addr=10.15.3.74 0 0 

我可能做错了,这使得docker集装箱不能正确地获取安装位置?