Docker Swarm Notes

Submitted by code_admin on Thu, 01/16/2020 - 08:40

Docker commands I use when managing Swarm

Init Swarm

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

  1. docker node update --label-add foo --label-add bar=baz node-1

Find labels on a node

  1. docker node inspect ict-rjmetcal | jq '.[] | .Spec.Labels'

Constrain a service to a label in compose

  1. version: "3.1"
  2.  
  3. services:
  4.   db:
  5.     image: mysql:5.7
  6.     deploy:
  7.       placement:
  8.         constraints:
  9.           - node.labels.disk == ssd
  10.       restart_policy:
  11.         condition: on-failure
  12.  

Constrain a service to a label in service command

  1. docker service create \
  2.   --name redis_2 \
  3.   --constraint 'node.labels.type == queue' \
  4.   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…

Tags

RJM Article Type
Quick Reference