I am new to docker swarm and want to understand, how docker stack deploy works
version: '3'
services:
web:
image: nginx
ports:
- "80:80"
redis:
image: "redis:alpine"
When I run this command, it works perfectly fine
$ docker stack deploy -c docker-compose.yml mystack
Creating network mystack_default
Creating service mystack_web
Creating service mystack_redis
To verify it
$ docker stack ps mystack
ID NAME IMAGE NODE
DESIRED STATE CURRENT STATE ERROR PORTS
rcci590y5c6o mystack_redis.1 redis:alpine
plakhera1.example.com Running Running 9 seconds ago
lty84a77b4my mystack_web.1 nginx:latest
plakhera2.mylabserver.com Running Running 2 seconds ago
Now my question is how to make sure that every time I deploy this application/service Redis will come up on plakhera1.example.com and nginx on plakhera2.example.com. I believe currently its picking nodes randomly, so how can I make sure it always pick only those nodes.
Update: The scenario is my web is the basic app but the Redis does a lot of heavy lifting, that why I always want Redis to be on the beefy node, is there is any way I can specify via docker stack deploy that web always boots up on node1 and Redis on node2