Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to specify Container deployment Node in docker swarm Cluster

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to specify container deployment nodes in docker swarm cluster. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

In docker swarm clusters, containers are usually deployed randomly to each node by default. However, it is sometimes encountered in deployment that some services are specified on a special machine.

If this happens, we can take advantage of the deploy.placement.constraints attribute in the docker-compose.yml file

1. Specify a manager or work node

Deploy: replicas: 1 placement: constraints: # # commonly used to specify manager or work nodes-node.role = = worker

two。 Specify hostname

Deploy: replicas: 1 placement: constraints:-node.hostname = = docker1

3. Specify node label

Node label can label one or more machines, and then specify the node tag in the compose file, which can be deployed on the machine with the corresponding tag. The specific steps are as follows:

Now label all the node machines on the master node machine, and the command is as follows:

Docker node update-- label-add role= tag name hostname for example, I'm going to label a machine with the hostname docker1 with the label db docker node update-- label-add role=db docker1.

Then, configure the compose file

Deploy: replicas: 1 placement: constraints:-node.labels.role = = db

Commands to delete node tags

Docker node update-- label-rm role tag name

4. Specify node id

Check the id of node first, and the command is as follows:

Docker node ls

As shown in the figure:

Deploy: replicas: 1 placement: constraints:-node.id = = xy4ttvg3xqbvwu4lok2xpgmrc

5. According to the engine tag

Deploy: replicas: 1 placement: constraints:-engine.labels.operatingsystem==ubuntu 14.04 so much about how to specify container deployment nodes in the docker swarm cluster. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report