I am unable to understand if I need application configurations and images loaded in docker on all nodes for docker swarm to work properly?
For example I have app with following dependencies: App -> requires db running App -> also requires volume mount for storing configuration files
So do I need these volumes created with same path on all nodes?
You can define your volume in the
docker-compose.ymlfile and theDocker Enginewill create it on the node where the service runs. Details:Example:
Note:
docker-composeis not needed to operate withDocker Swarm. But the mechanism is the same.The volume is node specific, so the data is stored in the file system on the node/server. It means if your service can run on different nodes then the content of the volume won't be the same on different nodes. In other words, the content of volumes are not synced between the nodes.
Here is a representation of it:
As you can see in the above pictures the volume is re-created on the "Host C" after re-deployment and the Redis service is not able to access to volume on "Host A".
Here is a good article about persistent storage mechanism for Docker. It describes what happens with your volume if it starts on different node (Re-created):
BUT, there is solution to share the data between machines/nodes. It's not a pure Docker solution but there is a part for it in the official
Dockerdocumentation:Another good description about shared persistent storage with
Docker: