我一直在尝试获取图像信息以尝试遵循文档:
This doc specifically
list(**kwargs)
List images on the server.
Parameters:
- name (str) — Only show images belonging to the repository
name
- all (bool) — Show intermediate image layers. By default,these are filtered out.
- filters (dict) — Filters to be processed on the image list. Available filters: –
dangling
(bool) –label
(str): format eitherkey
orkey=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:过滤器(dict)
此外,教程示例https://docker-py.readthedocs.io/en/stable/user_guides/swarm_services.html#listing-services为过滤器提供了一个字典,尽管对于服务而言,它也应适用于图像.
因此,请尝试:
client.images.list(filters = {‘dangling’:True})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。