gpt4 book ai didi

python - docker-py 客户端的意外行为

转载 作者:行者123 更新时间:2023-12-01 03:28:28 27 4
gpt4 key购买 nike

我正在尝试运行 docker-py 包的入门文档 ( https://docker-py.readthedocs.io/en/stable/index.html#getting-started ) 中的一些基本代码,但在 Python 2.7.6 和 Python 3.4.3 中都遇到了问题:

>>> client = docker.from_env()
>>> client.images.list()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'list'

奇怪的是,我可以看到这样的图像列表:

client.images()
[{u'Created': 1476822682, u'Labels': None, u'VirtualSize': 4802964, u'ParentId': u'', u'RepoTags': [u'alpine:3.4'], u'RepoDigests': [u'alpine@sha256:1354db23ff5478120c980eca1611a51c9f2b88b61f24283ee8200bf9a54f2e5c'], u'Id': u'sha256:baa5d63471ead618ff91ddfacf1e2c81bf0612bfeb1daf00eb0843a41fbfade3', u'Size': 4802964}]

根据文档,这似乎是意外行为。为什么 client.images 是一个列表,而不是 Images 类的实例(如下所示: https://docker-py.readthedocs.io/en/stable/images.html ),正如文档似乎暗示的那样?我一定错过了一些简单的东西。有什么想法吗?

最佳答案

想通了。我已经用 pip 安装了 docker-py,但该包的当前版本在 pypi 上简称为“docker”。

关于python - docker-py 客户端的意外行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41212024/

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