我一直在尝试了一段时间才能得到的图像信息,试图按照文档:此文档专门
清单(** kwargs)
列出服务器上的图像。
参数:
- 名称(str)-仅显示属于存储库的图像
name
- 全部(bool)-显示中间图像层。默认情况下,这些被过滤掉。
- 过滤器(dict)-要在图像列表上处理的过滤器。可用的过滤器
dangling
:-(布尔)-label
(str):格式化key
或key=value
现在,当我尝试并且尝试了很多事情时,我无法找出正确的语法:
sh-4.2# python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> client = docker.from_env()
>>> for image in client.images.list('dangling'):
... print image.id
...
>>> for image in client.images.list('dangling=true'):
... print image.id
...
>>>
我也尝试过其他方法,但无法弄清楚它是如何工作的。我需要的实际上是通过悬挂或不悬挂来过滤它们。
根据上面的解释,它说它需要一个dict: filters (dict)
另外,位于https://docker-py.readthedocs.io/en/stable/user_guides/swarm_services.html#listing-services的教程示例为过滤器提供了一个指示,尽管对于针对图像的服务也是如此。
因此,请尝试:
client.images.list(filters={'dangling': True})
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句