Docker Community Forums

Share and learn in the Docker community.

Docker Volume File permission and locking

(Aziksa) #1

When a docker volume is shared across multiple containers and users are collaborating on same set of files, how does docker architecture manage the file locking for read and write. Our requirement is to lock the file for one user and keep it open to read for rest in the group in a real time environment similar to web conferencing of sharing screen one at a time. Can this be achieved using a docker plug-in? Thanks for your help.

(David Maze) #2

It doesn’t. Imagine multiple copies of the same process running on the same local system with the same filesystem; the application needs to work out this locking for itself.

(Since it is, in fact, multiple copies of the same process on a shared local filesystem, normal things like flock(2) should work, though.)


Hi there ! So i was using flock so that two containers can’t use the same file at the same time on shared volume.i.e, if one container proceeds with flock then other container should be blocked but it seems like only 4 out of 10 times one of the container is blocked on flock whereas 6 times flock succeeds for both the containers. What could be the reason behind this and how can i debug this ?