Open sebgie opened 8 years ago
Hey @sebgie,
The confusion comes from the fact that we have two set of labels:
docker node update
)--label
)Label filtering in docker node ls
is looking at engine labels rather than node labels.
We should probably revert to node label filtering rather than engine filtering
/cc @aaronlehmann @dperny @nishanttotla
Hi, @aluzzardi
I think currently the way how docker deals the label is very important for users. I put forward a PR https://github.com/docker/docker/pull/28192 to include more description on docker node ls -f "label=a"
Any update on this? This ticket is labeled with the 1.13.0 milestone, but that has already gone out.
Yeah, as @aluzzardi mentioned. Currently swarmkit still takes engine labels as node filtering. I think we should support both. Open a pr https://github.com/docker/swarmkit/pull/2062 to make it. PTAL
I was really feeling that I was crazy given that I couldn't get the list filtered haha. Nice to know about this issue and that there's already a PR that solves it.
In the mean time, I'm counting the number of nodes with a given label like this:
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
88bd4sz9irxh1f5cylfeeft1c ip-172-31-25-51.us-west-2.compute.internal Ready Active
aa7c1vcg9a13hbdmjizyrcr9s ip-172-31-13-77.us-west-2.compute.internal Ready Active
e4rzm599p27hzrtrcaahpi1dd ip-172-31-25-8.us-west-2.compute.internal Ready Active
guc2m14qt53y9z769p6zlgh6k ip-172-31-41-228.us-west-2.compute.internal Ready Active
ibl03o334qrdmk7r0liwuyhhm ip-172-31-44-53.us-west-2.compute.internal Ready Active
motlc6ulkijxk1cnlk7x13bdr * ip-172-31-35-137.us-west-2.compute.internal Ready Active Leader
~ $ docker node update --label-add type=infra 88bd4sz9irxh1f5cylfeeft1c
88bd4sz9irxh1f5cylfeeft1c
~ $ docker node update --label-add type=test e4rzm599p27hzrtrcaahpi1dd
e4rzm599p27hzrtrcaahpi1dd
~ $ nodes=$(for node in $(docker node ls -q); do docker node inspect $node; done)
~ $ echo $nodes | jq '.[] | .Spec.Labels | select(has("type")) | .type'
"infra"
"test"
(github says that I unassigned @nishanttotla (????))
Still not implemented?
Funny that I just came across your comment @IvanBoyko, I am trying to set up a multiplatform infrastructure and I was wondering why my node labels weren't working! It would have been nice to know!
The issue is still present and quite annoying, since it is not mentioned within the documentation. So it would be really great to at least update the official documentation. This is problem is more than two years old...
Current status looks to be that @allencloud have created PR docker/swarmkit#2062 about 1,5 years ago but it was not ever updated based on review so it was not merged and based on https://github.com/docker/swarmkit/pull/2062#issuecomment-302851163 it looks to be that he will not continue that work.
So it would be best that someone else who have need for this one will continue that work. I have couple of other PRs which with I'm working on so I cannot look this on near future and we actually don't have big need for this as our server provisioning sets engine labels for all servers by default. If you need help you can contact me on Slack.
@Stephan-Walter you can create PR which updates documentation https://github.com/docker/docker.github.io / https://github.com/docker/cli (I have not time to investigate now which one those documents currently exists).
Any update?
Every developer goes for Kubernetes. That's how we get this 4 years old issue.
@custom20s honestly if you really need this feature then you should implement it. On nowadays DevOps world coding skill is coming more and more critical for Ops too and those are not able to do coding will be left behind.
Golang is quite simple to learn and I can help you getting started on Slack.
Looks like this was implemented in https://github.com/moby/moby/pull/37650, but the documentation was not updated to mention the node.label
filter;
$ docker node update --label-add test swarm-test-04
swarm-test-04
$ docker node update --label-add test2 swarm-test-02
swarm-test-02
$ docker node ls --filter node.label=test
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
n41b2cijmhifxxvz56vwrs12q swarm-test-04 Ready Active 20.10.0
$ docker node ls --filter node.label=test2
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
2lm9w9kbepgvkzkkeyku40e65 swarm-test-02 Ready Active Reachable 20.10.0
opened https://github.com/docker/cli/pull/2951 to update docs and completion scripts
Description
Hi, I have started to use 1.12 with it's new features lately. I have a 4 node cluster (1 manager, 3 workers with swarm mode) and try to put workloads on dedicated machines. While doing that I came accross either a bug or something that is missing from documentation?
I have added a label to one of my nodes and then try to execute
docker node ls
with a filter as described here: https://docs.docker.com/engine/reference/commandline/node_ls/#filtering. Unfortunately I don't get the expected response?Steps to reproduce the issue:
Describe the results you received: No nodes found.
Describe the results you expected: One node (dev-swarm-04) found.
Additional information you deem important (e.g. issue happens only occasionally): Additonally I couldn't find any documentation how I would use a value with my label.
# docker node ls -f label=test=value
?# docker node ls -f label=test:value
?# docker node ls -f label.test=value
?Using the label as a constraint to create a service works flawlessly :+1:. Thanks for your help :).
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.): Ubuntu 16.04