Skip to content

Docker Swarm

commands

Get labels from nodes in swarm cluster Execute on manager

docker node ls -q | xargs docker node inspect -f '[{{ .ID }} {{ .Description.Hostname }}]: {{ .Spec.Labels }}'

docker node ls -q | xargs docker node inspect \
  -f '{{ .ID }} [{{ .Description.Hostname }}]: {{ range $k, $v := .Spec.Labels }}{{ $k }}={{ $v }} {{end}}'