How to share data between container (same service)

I run an apache service on 3 nodes using swarm :
docker service create --name my-apache --publish 8081:80 --replicas 3 apache-php

Users of my web site upload pictures and I want to share this data between all the apache container.

Is there a way to use Data Volume Container to do this ?
I see the --mount option in service create but don’t find documentation about it.
I see that a “global” mode exist for data volume (here) but don’t find any information.

could you help me solving my problem ?


I find this discussion (without really answer in it :frowning: ) about my problem :

There’s Flocker ( which is a volume plugin for Docker that persists/replicates data across all of the nodes in the cluster, so it doesn’t matter in which node your process is allocated, it will have the data available.

You might want to check that out.

I fonud btsync also (

So I create service for btsync :
docker service create --mount type=volume,source=hello,target=/data …

and use the volume for my apache :
docker service create --name demo --mount type=volume,source=hello,target=/var/www/html/ …

Not sure what your app/site is, but have you considered AWS S3 rather than local storage? It is a simple API. If this is just a personal project, you may not want this.

For a small number of containers, you can create a single volume that is mounted by multiple containers through a standard mount point, and eliminate the traffic/load of syncing files.

  1. docker create -v /data --name datavol1 <generic_base_image> /bin/true
  2. docker run -d --volumes-from datavol1 --name my-apache --publish 8081:80 --replicas 3 apache-php

(you don’t need to start the container created in the first step, just the shared resource)