jojo jojo - 1 year ago 120
Linux Question

can we deploy a container into a specific node in a docker swarm

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 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.

Answer Source

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 ...

This would start the container on node1.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download