Is it safe / possible to use flock in a docker swarm?
I'm looking for a safe way for multiple containers to write to the same file (on the same volume). I know that on a single host docker will bind mount. What I'm not certain about is how this works when spinning up containers via docker-compose on a swarm.
If I have multiple instances of the same image in a service and these all share a volume then when I start this on a swarm will the containers be started on separate hosts? If so how will the the volume be shared at an OS level? What synchronisation options do I have for controlling concurrent writes?
Create a NFS volume
Example: