2017-10-04 107 views
0

碼頭版本顯示正確的API版本的客戶端和服務器時,我運行裏面的Python它拋出錯誤如下。碼頭API客戶端/服務器版本不匹配?

# docker version 
 
Client: 
 
Version:   1.12.6 
 
API version:  1.24 
 
Package version: docker-1.12.6-48.git0fdc778.el7.x86_64 
 
Go version:  go1.8.3 
 
Git commit:  0fdc778/1.12.6 
 
Built:   Thu Jul 20 00:06:39 2017 
 
OS/Arch:   linux/amd64 
 

 
Server: 
 
Version:   1.12.6 
 
API version:  1.24 
 
Package version: docker-1.12.6-48.git0fdc778.el7.x86_64 
 
Go version:  go1.8.3 
 
Git commit:  0fdc778/1.12.6 
 
Built:   Thu Jul 20 00:06:39 2017 
 
OS/Arch:   linux/amd64 
 
#

但是,當我與Python運行它拋出如下錯誤。

# python 
 
Python 2.7.5 (default, Aug 29 2016, 10:12:21) 
 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2 
 
Type "help", "copyright", "credits" or "license" for more information. 
 
>>> import docker 
 
>>> client = docker.APIClient(base_url='unix://var/run/docker.sock') 
 
>>> print client.version() 
 
Traceback (most recent call last): 
 
    File "<stdin>", line 1, in <module> 
 
    File "/usr/lib/python2.7/site-packages/docker/api/daemon.py", line 177, in version 
 
    return self._result(self._get(url), json=True) 
 
    File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 226, in _result 
 
    self._raise_for_status(response) 
 
    File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 222, in _raise_for_status 
 
    raise create_api_error_from_http_exception(e) 
 
    File "/usr/lib/python2.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception 
 
    raise cls(e, response=response, explanation=explanation) 
 
docker.errors.APIError: 400 Client Error: Bad Request ("client is newer than server (client API version: 1.30, server API version: 1.24)") 
 
>>>

回答

0

從錯誤中,它看起來像的版本在碼頭工人的API客戶端和服務器碼頭工人的不匹配。你有沒有嘗試升級碼頭服務器?

+0

這不是提供答案,請發表評論,而不是 – GGO

0

它說你的docker python包的API不符合docker引擎服務器API。您應該安裝與1.24兼容的docker python軟件包或將docker engine API更新至1.30。

此外,還可以嘗試將泊塢窗客戶端分配新值,如下所示:

客戶端= docker.DockerClient(BASE_URL = 'UNIX://var/run/docker.sock',版本= 「1.24」 )

OR

客戶端= docker.APIClient(BASE_URL = 'UNIX://var/run/docker.sock',版本= 「1.24」)

相關問題