Docker commands I use when managing Swarm
Init Swarm
- 
docker swarm init --advertise-addr xx.xx.xx.xx --data-path-port=7789
 
Data path port needs to be changed due to VM conflict: "VTEP Port is reserved or restricted for VMware use, any virtual machine cannot use this port for other purpose or for any other application."
On nodes use --advertise-addr with join
Add label to node
- 
docker node update --label-add foo --label-add bar=baz node-1
 
Find labels on a node
- 
docker node inspect ict-rjmetcal | jq '.[] | .Spec.Labels'
 
Constrain a service to a label in compose
- 
version: "3.1"
 - 
 - 
services:
 - 
db:
 - 
image: mysql:5.7
 - 
deploy:
 - 
placement:
 - 
constraints:
 - 
- node.labels.disk == ssd
 - 
restart_policy:
 - 
condition: on-failure
 - 
 
Constrain a service to a label in service command
- 
docker service create \
 - 
--name redis_2 \
 - 
--constraint 'node.labels.type == queue' \
 - 
redis:3.0.6
 
Connection debug
https://gist.github.com/alexellis/8e15f2ea1af7281268ec7274686985ba#file…
Links
https://docs.docker.com/engine/swarm/manage-nodes/
Tracing packets - https://medium.com/@xxradar/how-to-tcpdump-effectively-in-docker-2ed0a0…
RJM Article Type
              Quick Reference