[英]Is it possible to assign a specific node to create container with docker swarm?
When creating new containers, it follows the swarm's strategy to select a node 在创建新容器时,它遵循swarm的策略来选择节点
I don't want to issue the command against the node directly if it have to work on that specific one. 我不想直接发出针对该节点的命令,如果它必须在该特定节点上工作。
Is there a way to tell swarm to work on a specific node? 有没有办法告诉swarm在特定节点上工作?
UPDATE UPDATE
According to @DAXaholic 's reply, by default daemon option Lable
can be the callable tag. 根据@ DAXaholic的回复,默认守护进程选项
Lable
可以是可调用标记。
So, I edit /etc/default/docker
, add --label
to DOCKER_OPTS
. 所以,我编辑
/etc/default/docker
--label
,将--label
添加到DOCKER_OPTS
。
After restart services, node is able to called by specific label values. 重新启动服务后,节点可以通过特定标签值进行调用。
Yes you can do that with filters 是的,你可以用过滤器做到这一点
So the idea is essentially you give your nodes tags that describe them like 'node-with-gpu' or something like that. 所以这个想法基本上就是你给你的节点标签描述它们像'node-with-gpu'之类的东西。
There is also a default tag 'node' which you can use to filter for a specific node 还有一个默认标记“node”,您可以使用它来过滤特定节点
So an example to run Redis on node1
could look like this 因此,在
node1
上运行Redis的示例可能如下所示
$ docker tcp://<manager_ip:manager_port> run -d --name redis1 -e
constraint:node==node1 redis
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.