docker-py 0.7.0 gives me the following error against a local Docker installation of Docker 1.3.2 and docker-py 0.7.0. The host ist running CentOS 6.6. How can this be fixed?
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
got the same problem yesterday. Force install docker-py=0.6.0. If you already have 0.7.0 installed, you need to clear your pip cache, otherwise pip will install 0.7.0 from your cache.
Cheers, W
Solution if the client version is newer than the server version:
Say you want to connect to your docker service like this:
docker_client = Client(base_url='tcp://127.0.0.1:2376')
# Alternatively:
# docker_client = Client(base_url='unix://var/run/docker.sock')
If the client version is newer than the server version, this leads to an error message like this:
docker.errors.NotFound: 404 Client Error:
Not Found ("client and server don't have same version (client : 1.22, server: 1.18)")
You can solve the problem by setting the version property
of the docker.Client object (as @sredni suggested). Given the error above, you need to change the line to:
docker_client = Client(base_url='tcp://127.0.0.1:2376', version='1.18')
This is not a bug docker-py is trying to use latest avaliable docker api. If you have latest docker everything is ok, if not you just need to pass 'version' into Client.
https://github.com/docker/docker-py/blob/0.7.0/docs/api.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With