Machine constraints in Docker swarm

Hello everyone:

I wanted to know if there is a way to specify constraints for Dockers launched with Swarm. The idea is to use Swarm to start Docker containers across the cluster following a certain workflow

e.g. first start container C1 on Machine A. After that containers C2, C3 and C4 on machines B, C and D. Finally start some container C5 on machine E.

All this Docker containers will have to communicate between each other. Is that possible with Swarm?

Yes you can achieve this by placing constraints on the nodes and for communication use overlay network.

For deploying containers on particular node machine in swarm.
docker node update --label-add ‘ip=xxx’ <node_id>
docker network create -d overlay swarm_net

docker service create --constraint ‘node.labels.ip==xxx’ --name --network swarm_net