docker-py 0.7.0对Docker 1.3.2的本地Docker安装给出了以下错误 和docker-py 0.7.0。主持人正在运行CentOS 6.6。如何解决这个问题?
xxxx@dev1 myproject]$ bin/python d.py
Traceback (most recent call last):
File "d.py", line 3, in <module>
c.create_container(image='zopyx/xmldirector-plone')
File "/home/xxxx/sandboxes/myproject/lib/python2.7/site-packages/docker/client.py", line 546, in create_container
return self.create_container_from_config(config, name)
File "/home/xxxx/sandboxes/myproject/lib/python2.7/site-packages/docker/client.py", line 554, in create_container_from_config
return self._result(res, True)
File "/home/xxxx/sandboxes/myproject/lib/python2.7/site-packages/docker/client.py", line 98, in _result
self._raise_for_status(response)
File "/home/xxxx/sandboxes/myproject/lib/python2.7/site-packages/docker/client.py", line 94, in _raise_for_status
raise errors.APIError(e, response, explanation=explanation)
docker.errors.APIError: 404 Client Error: Not Found ("client and server don't have same version (client : 1.16, server: 1.15)")
>>docker --version
Docker version 1.3.2, build 39fa2fa/1.3.2
>>docker version
Client version: 1.3.2
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 39fa2fa/1.3.2
OS/Arch (client): linux/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa/1.3.2
答案 0 :(得分:2)
昨天遇到了同样的问题。强制安装docker-py = 0.6.0。如果您已安装0.7.0,则需要清除pip缓存,否则pip将从缓存中安装0.7.0。
干杯, w ^
答案 1 :(得分:2)
解决方案,如果客户端版本比服务器版本新:
假设你想连接到这样的docker服务:
docker_client = Client(base_url='tcp://127.0.0.1:2376')
# Alternatively:
# docker_client = Client(base_url='unix://var/run/docker.sock')
如果客户端版本比服务器版本新,则会出现如下错误消息:
docker.errors.NotFound: 404 Client Error:
Not Found ("client and server don't have same version (client : 1.22, server: 1.18)")
您可以通过设置docker.Client对象的version property
来解决问题(建议使用@sredni)。鉴于上述错误,您需要将行更改为:
docker_client = Client(base_url='tcp://127.0.0.1:2376', version='1.18')
答案 2 :(得分:1)
这不是一个bug docker-py试图使用最新的avaliable docker api。如果你有最新的码头工具,一切都还可以,如果不是,你只需要通过&#39;版本&#39;进入客户。