Ansible fancy
Ansible fancy

Reputation: 25

Labels in docker swarm - how does it work?

we know that on command: docker node inspect <id of node> we got (among others) labels.

How these labels are organized? Some enviroment variable?

And in general: I added some lable to node using docker node update command. How does it work? I mean who and how notice this fact (new label) and do actual actions?

Upvotes: 0

Views: 4100

Answers (1)

leninhasda
leninhasda

Reputation: 1730

labels are way to add extra metadata to your docker images, containers, networks, swarm nodes etc. Once added these label(s) allows you to filter your docker resources.

For example following command let's you see all the running containers:

docker ps

Now lets say you want to see the running containers that has project label:

docker ps --filter "label=project"

Ok how about only the containers who are part of user service (has label project=user-app)

docker ps --filter "label=project=user-app"

Here is the full documentation about docker labels: https://docs.docker.com/config/labels-custom-metadata/

Upvotes: 1

Related Questions