Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 785
jojo Avatar asked Apr 13 '16 21:04

jojo


People also ask

Which two types of nodes can you deploy in a docker Swarm?

A swarm consists of one or more nodes: physical or virtual machines running Docker Engine 1.12 or later in swarm mode. There are two types of nodes: managers and workers.


Video Answer


1 Answers

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.

like image 56
Erik Dannenberg Avatar answered Sep 23 '22 16:09

Erik Dannenberg