Docker Community Forums

Share and learn in the Docker community.

Support --label-add on docker swarm join

When nodes add themselves to a swarm, it is a nice opportunity to set some labels using information available locally. Currently this requires using docker node update instead which won’t work on worker nodes, which makes it harder to get the information available locally added as node labels.

So, something like this would be nice:

docker swarm join \
   --token SWMTKN-1-5u73v65jpqeq1x1noh4ech6d5q83bumjd0kma7l1aft93rspnz-d8rx56ksb14bwkube2r8r7d86 \
   --label-add foo=bar 
    192.168.77.21:2377 

This would add the node and set the node labels at the same time so there is no need for a separate docker node update --label-add foo=bar from a different machine.

2 Likes

This is what I wanted!

If you’d like to set labels on a worker node itself you should use dockerd labels.

Adding node labels is a more highly privileged operation and should only be done from managers. This can be used to restrict some workloads to certain nodes. There’s a small explanation here.