简体   繁体   中英

Docker for Windows unable to mount nfs drive with docker-compose

permission denied errors when attempting to mount an nfs drive to a docker container using a docker-compose file.

This error only applies when running Docker for Windows. I am able to successfully mount the drive on an Ubuntu host.

docker-compose file

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>"

Docker for Windows Produces

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"

The following worked for me with Docker Toolbox on Windows 7 mounting a NFS volume from an Ubuntu server:

NFS Server side:

  • allow the nfs and mountd services on your firewall (if you have one) on the NFS server
  • add the insecure option in each relevant entry of your '/etc/exports' file

Docker client side: add the hard and nolock options to the NFS volume definition

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>"

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