Windows版Docker无法通过docker-compose挂载NFS驱动器

时间:2019-06-04 13:25:13

标签: docker docker-compose

尝试使用docker-compose文件将nfs驱动器安装到docker容器时,权限被拒绝的错误。

此错误仅在运行Docker for Windows时适用。我能够在Ubuntu主机上成功安装驱动器。

docker-compose文件

version: '2'

services:
   builder:
     image: some_image
     ports:
     - "8888:8080"
     volumes:
     - "nfsmountCC:</container/path>"

 volumes:
   nfsmountCC:
     driver: local
     driver_opts:
       type: nfs
       o: addr=<nfs_IP_Address>
       device: ":</nfs/server/dir/path>"

适用于Windows的Docker产生

ERROR: for test_1  Cannot start service builder: b"error while mounting volume '/var/lib/docker/volumes/test-master_nfsmountCC/_data': error while mounting volume with options: type='nfs' device=':</nfs/server/dir/path>' o='addr=<nfs_IP_Address>': permission denied"

1 个答案:

答案 0 :(得分:0)

以下内容适用于Windows 7上的Docker Toolbox,它从Ubuntu服务器上挂载了NFS卷:

NFS服务器端:

  • 允许NFS服务器上的防火墙(如果有)上的 nfs mountd 服务
  • 在“ / etc / exports”文件的每个相关条目中添加不安全选项

Docker客户端:在NFS卷定义中添加 hard nolock 选项

version: '3.7'

services:
  builder:
    image: some_image
    ports:
      - "8888:8080"
    volumes:
      - "nfsmountCC:</container/path>"

volumes:
  nfsmountCC:
   driver: local
   driver_opts:
     type: nfs
     o: "addr=<nfs_IP_Address>,rw,hard,nolock"
     device: ":</nfs/server/dir/path>"