How to run the container on specific node in swarm mode

Hi, I tried to use “docker run” to create a container on a specific swarm node, but it seems docker always create the node on the swarm master node, is this expected behavior or something I have done wrong, thanks for the advice.

On swarm master node:
wangy@csx00309:~$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
2aea35f94k0z7iy7j5l02h7up csx00153 Ready Active
2j3yy1jqru9tlmhcje71491ww * csx00309 Ready Active Leader

wangy@csx00309:~$ docker run -itd --name test3 --hostname test3 -e constraint:node=csx00153 --network bpm_default ubuntu:14.04 sleep 10000
26fdfc06741cc841f3a1f8f3cbad963dca9d96564b063c0dea84aa849b54573c

wangy@csx00309:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
26fdfc06741c ubuntu:14.04 “sleep 10000” 5 seconds ago Up 3 seconds test3

On swarm worker node csx00153:
wangy@csx00153:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

1 Like

Hi,

Looking to you command seem it laks of one = simbol. The filter option needs doble equal sign.

Try please:

docker run -itd --name test3 --hostname test3 -e constraint:node==csx00153 --network bpm_default ubuntu:14.04 sleep 10000

Bye