docker mount nfs with local_lock=all

▼魔方 西西 提交于 2021-02-18 22:33:27

问题


I have docker-compose.yml file

volumes:
  nfs:
      driver: local
      driver_opts:
        type: nfs
        o: addr=192.168.100.1,rw
        device: ":/mnt/storage"

my container have mounted volume with options:

type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.100.1,mountvers=3,mountproto=tcp,local_lock=none,addr=192.168.100.1)

with local_lock=none and i can't change this option to local_lock=all I tried:

volumes:
  nfs:
      driver: local
      driver_opts:
        type: nfs
        o: addr=192.168.100.1,rw,local_lock=all
        device: ":/mnt/storage"

and

volumes:
  nfs:
      driver: local
      driver_opts:
        type: nfs
        o: addr=192.168.100.1,rw
        device: ":/mnt/storage"
        local_lock: all

but nothing changes


回答1:


A workaround that doesn't answer the question is to create NFS mounts directly on the host, and then export the mounted folder to a docker volume. This way, NFS locks are no longer required on Docker containers.

Not an ideal solution for Docker Swarm, since it requires maintaining NFS mounts on each node of the swarm.




回答2:


The syntax you want is the first option:

volumes:
  nfs:
      driver: local
      driver_opts:
        type: nfs
        o: addr=192.168.100.1,rw,local_lock=all
        device: ":/mnt/storage"

That is just a pass through to the OS. The reason you likely don't see any difference with that volume mount is that local_lock is listed as an NFS 2 or NFS 3 only option, so if you're using NFS 4 that option is likely ignored.



来源:https://stackoverflow.com/questions/42265717/docker-mount-nfs-with-local-lock-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!