我们可以将容器部署到docker swarm中的特定节点中吗 [英] can we deploy a container into a specific node in a docker swarm
本文介绍了我们可以将容器部署到docker swarm中的特定节点中吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个docker swarm集群,它包含1个主节点和3个节点.当我们通过swarm master部署容器时,例如使用以下命令
I have a docker swarm cluster, it contains 1 master 3 nodes. When we deploy a container through swarm master, e.g with the below command
docker -H tcp://<master_ip>:5001 run -dt --name swarm-test busybox /bin/sh
Swarm将自动选择一个节点并部署我的容器.有没有办法手动选择节点?例如,我想在节点1中部署一个容器.
Swarm will auto pick a node and deploy my container. Is there a way to hand pick a node? e.g I want to deploy a container in node 1.
推荐答案
看看虫群过滤器文档.您可以对Swarm应该为任何给定容器选择的节点设置各种约束.对于您的情况,请尝试以下操作:
Take a look at the Swarm filter docs. You can set various constraints on what node Swarm should pick for any given container. For your case try something like:
docker run ... -e constraint:node==node1 ...
这将在node1
上启动容器.
这篇关于我们可以将容器部署到docker swarm中的特定节点中吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文