According to that StackOverflow answer:

Yes you can add same location as a volume to many docker containers.

But I read the Docker Volume documention and I can't find where it is said a local volume can safely be shared between several containers on the same host. Could someone point me to an official statement regarding that?

  • It is the same as sharing the same directory between multiple process. /var/log is usually written into by multiple process in a system. – Tensibai Feb 26 '19 at 15:39
  • Well, what confuses me @Tensibai is volumes are mounted several times. Given the way the Linux kernel handles mounts, it isn't a problem to mount the same device at different locations. But is this just a happy consequence of that, or a supported feature guaranteed to work the same on non-Linux Docker platforms (ie, with Windows Native containers)? – Sylvain Leroux Feb 26 '19 at 18:06
  • 1
    Technically, they are only mounted once in each container, and at the end of the day, that's not a real mount, that's more a hole in the name spaces where a process in namespace A is allowed to access filesystem in 'host' namespace – Tensibai Feb 27 '19 at 7:37
  • Define "safe". Will it work? Yes. Will you get problems if multiple containers read/write the same set of files? Yes. – Raphael Feb 27 '19 at 9:48

By a "local volume" I assume you mean a block device directly attached to the host, such as a "normal" internal disk.

The standard way to run multiple Docker, containers now is Kubernetes, since the demise of Docker Swarm. My reference here is the Kubernetes documentation for Persistent Volumes specifically the table on Access Modes, and the column for ReadWriteMany. A local volume would be a HostPath which is not supported for this use case. However if you were using iSCSI it would support ReadOnlyMany, and if you used NFS you could get ReadWriteMany.

  • 1
    Searching for the demise of swarm I can only find articles that say that Swarm isn’t demised it is simply that Docker EE will also support k8s. Do you have an official link that says otherwise? – simbo1905 Mar 4 '19 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.