docker / cli

The Docker CLI
Apache License 2.0
4.94k stars 1.93k forks source link

Option to output node labels in node ls format #1953

Open kinghuang opened 5 years ago

kinghuang commented 5 years ago

Description

The docker node ls command takes a --format option to customize the output. My nodes are labeled with metadata like the availability zone and node group name. It would be really useful to be able to output labels when listing nodes.

Steps to reproduce the issue:

  1. Attempt to output a list of nodes with foo labels.
docker node ls --format 'table {{ .ID }}\t{{ .Label.foo }}'

Describe the results you received:

It is not possible to output all labels, or a specific label.

Template parsing error: template: :1:19: executing "" at <.Label.foo>: can't evaluate field Label in type *node.nodeContext

Describe the results you expected:

An option to output one or more labels.

Additional information you deem important (e.g. issue happens only occasionally):

It is possible to filter nodes by label.

docker node ls --filter "label=foo"

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.0-rc2
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.5
 Git commit:        f97efcc
 Built:             Wed Jun  5 01:37:53 2019
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 02:02:43 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

N/A

Additional environment details (AWS, VirtualBox, physical, etc.):

adeniyistephen commented 3 years ago

@GordonTheTurtle Hi, I would love to work on this, Please provide pointers and input on how to work on it. Thanks