问题
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