Basically we should have only one thread to write one file. But in docker environment, should we take care the concurrent problem on share file?

There exit two problems,

  1. How does Docker support for share volumes. How does file sync across instances.
  2. Does docker support concurrent write on share file.
1

There are 1 answers

1
David Maze On

Ideally you would avoid file sharing between containers altogether. It especially doesn't work well in multi-host environments like Docker Swarm or Kubernetes: there is no "file syncing across instances". Better practice is to communicate between containers using a well-defined network API, most often HTTP.

If you have multiple containers on the same host that mount the same content, Docker doesn't provide any special support here. It acts in the same way as if you had multiple processes on the same host accessing the same physical file. You are responsible for implementing file locking and other synchronization mechanisms yourself.