How is concurrency managed in volumes when they are shared by multiple containers?

2/14/2018

How is concurrency managed in volumes when the volumes are shared by multiple containers?

-- Aman Raturi
docker
kubernetes

2 Answers

2/14/2018

As it would be on a single host with multiple processes, cause that's what it effectively is.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

2/14/2018

It is the same way how a shared path / directory / file is managed by multiple processes / applications without containers.

  1. Avoid parallel / simultaneous writes using locks, semaphores, mutexes and mutual exclusion.
  2. Be careful about stale / old data when reading from shared volume.
  3. Keep in mind things like eventual consistency, volume backups and data migration since the volume is shared by multiple containers.
  4. Make sure that the shared volume is not corrupted. If corrupted, have a recovery plan.
  5. Use dedicated storage servers so that containers can move in the cluster (hostPath and emptyDir in kubernetes do not move with pods).
  6. The underlying OS, disk, storage software / driver, LVM, filesystem will also handle IO concurrency.
-- Vikram Hosakote
Source: StackOverflow