docker - docker ps 过滤标签不存在或不等于一个值 [Go Template]
问题描述
我想选择没有键或值不等于某物的容器。我有了从这里使用并docker inspect
从这里检查密钥存在的想法
但这并不完全适合我的情况。我试过了
跑步
docker container inspect -f '{{if (ne (index $.Config.Labels "agent") "delete") }}{{.Id}} {{ end }}' $(docker ps -q)
我有
error calling ne: invalid type for comparison
跑步
docker container inspect -f '{{with .Config.Labels.agent}} {{if (ne . "delete") }}{{$.Id}}{{end}} {{else}} {{$.Id}} {{end}}' $(docker ps -aq)
我有
map has no entry for key "agent"
现在我很困惑。如何实现:带有标签agent!="delete"
或agent
键的过滤容器未分配值?
解决方案
推荐阅读
- javascript - 使用 JavaScript 将元素添加到 html 多级列表
- string - SSRS 2016 报告 - 从字符串参数填充表
- java - 如何返回 lambda 函数并通过作为参数传递给 Java 8 中的方法来使用?为什么我不能使用 :: 运算符?
- python - 多处理帮助。BrokenProcessPool 错误
- python-3.x - Python - 在一页中包含多个数字的 Pdf 文件(不包含子图!!)
- visual-studio - 如何防止 Visual Studio 或 Docker 更改主机端口号?
- excel - 如何编写一个完整的表达式来获得列的加权和?
- c# - 使用 C# MongoDB 驱动程序获取最后一条记录
- c# - 如何在 EF 中获取与组合列表(键/值)匹配的记录?
- npm - 无法在 shadow-cljs 项目中导入本地 wasm npm 包