Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
How to list docker swarm nodes with labels

How can I easy print all available docker swarm nodes with their labels?

Added labels to nodes like
$ docker node update --label-add type=one my_node_name
And default listing nodes with docker node ls not showing filters.

Additionally I can list label inspecting each node like:

$ docker inspect my_node_name | grep type 
"type": "one"

---EDIT--

Similar question How do I filter docker swarm nodes by label? is about filtering my is about listing

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can run something like:

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

You can adjust that to use a range for prettier formatting instead of printing the default map:

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

Feel free to update the formatted output to the fields you need.

over 4 years ago · Santiago Trujillo Report

0

PowerShell Core version:

docker node ls -q | `
  ForEach-Object { `
    docker node inspect $_ --format '{{ json . }}' | `
    ConvertFrom-Json -Depth 99 } | `
  Select-Object { $_.Description.Hostname }, { $_.Spec.Labels }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!