gpt4 book ai didi

docker - 如何按标签过滤 docker swarm 节点?

转载 作者:行者123 更新时间:2023-12-04 19:35:39 25 4
gpt4 key购买 nike

我正在运行 docker 1.12.1 并且无法通过标签进行节点过滤工作。
我首先添加“测试”标签:

$ docker node update --label-add test mr-host
mr-host

当我尝试通过它进行过滤时,没有显示任何节点:
$ docker node ls --filter label=test
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS

按名称等其他条件过滤工作正常:
$ docker node ls --filter name=mr-host
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
1c48m4msidbqwx7vj0lwib8ef * mr-host Ready Active Leader

当我检查节点时会显示标签:
$ docker node inspect mr-host
[
{
"ID": "1c48m4msidbqwx7vj0lwib8ef",
"Version": {
"Index": 4865874
},
"CreatedAt": "2016-10-12T15:20:10.463286132Z",
"UpdatedAt": "2016-10-13T16:29:03.113522485Z",
"Spec": {
"Labels": {
"test": ""
},
"Role": "manager",
"Availability": "active"
},
"Description": {
"Hostname": "mr-host",
"Platform": {
"Architecture": "x86_64",
"OS": "linux"
},
"Resources": {
"NanoCPUs": 10000000000,
"MemoryBytes": 67548012544
},
"Engine": {
"EngineVersion": "1.12.1",
"Plugins": [
{
"Type": "Network",
"Name": "bridge"
},
{
"Type": "Network",
"Name": "host"
},
{
"Type": "Network",
"Name": "null"
},
{
"Type": "Network",
"Name": "overlay"
},
{
"Type": "Volume",
"Name": "local"
}
]
}
},
"Status": {
"State": "ready"
},
"ManagerStatus": {
"Leader": true,
"Reachability": "reachable",
"Addr": "192.168.0.118:2377"
}
}
]

我究竟做错了什么?我很确定我已经正确地遵循了此处的文档: https://docs.docker.com/engine/reference/commandline/node_ls/#/id

最佳答案

简单的答案:这不像你想象的那样工作,但看起来他们可能会修复它。

引自 the Github issue :

The confusion comes from the fact that we have two set of labels:

Node labels (the ones you've been setting through docker node update) Engine labels (the ones that you set when you start docker daemon with --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

关于docker - 如何按标签过滤 docker swarm 节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40026638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com