I'm building a multi-tier env in AWS using ansible and Docker (running in Swarm). I have one master and 2 worker nodes. I'm using Docker stack to create services in the swarm using the following command:
docker stack deploy -c myStack.yml myTest
I have 2 questions:
Thanks in advance
Let's start with your second questions, since it is easier.
You can add label to your nodes, and then use constraint when you create your service (stack is the same). e.g
docker node update --label-add "role=worker" .... # on all your worker nodes
docker service create --constraint "node.labels.role==worker" ...
For your first question, you need data persistent. There are some solutions.
Flocker is a large solution. It has more support, more options and more secure. It is also much difficult to configure.
Blocker is the one I current using. It have to be install on every node, and I can confirm it is working and working very well. Syntax is like,
docker service create --mount type=volume,target=/data,source=vol-08a1211f22864700c,volume-driver=blocker ....
I hope this is enough info for you to start your research.