简体   繁体   中英

Docker container deployment to mulitple nodes in a swarm cluster

I have a swarm cluster of 6 worker nodes and 3 master nodes so a total of 9 nodes. I am having machines of different sizes in my swarm cluster. So there is a requirement that I need to deploy certain services (containers) on particular worker nodes as per the size of the node. I am aware we can have placement constraints in the docker-compose file and can specify the hostname.

Since I will be running 2 replicas of the service so swarm will create replicas on the same worker to which I have set the constraint. But I don't want the replicas to be running on the same worker node.

Can we have an option to specify multiple hostnames while setting the placement constraint? Please guide.

You can to combine some nodes by labels.

    docker node update --label-add ssd=fat_machine hostname1
    docker node update --label-add ssd=fat_machine hostname2

and define label in docker-compose

    constraints: [node.labels.ssd == fat_machine]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM