docker-py 1.5.0 fails to ping docker 1.8.3

Created on 7 Dec 2015  路  9Comments  路  Source: docker/docker-py

Right after I update the docker-py to 1.5.0, all the ping calls started to fail =(

I don't know if this is the desired behaviour but if it is, please disconsider this issue.

The result of the .ping is:

APIError: 400 Client Error: Bad Request ("client is newer than server (client API version: 1.21, server API version: 1.20)")
$pip freeze | grep docker-py && python --version && docker version
docker-py==1.5.0
Python 2.7.6
Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 05:37:18 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 05:37:18 UTC 2015
 OS/Arch:      linux/amd64
kinquestion

Most helpful comment

Fair points.

How about improving the exception message then? Something like:

You have requested daemon API version 1.21 but it supports only 1.20.
Either supply exact version to Client `Client(version="1.20")` or let
client pick it automatically: `Client(version="auto")`

All 9 comments

Don't know if this helps but the ping method was moved from client.py:602 to daemon.py:73 and the internal method _url changed. But I couldn't find out why this fails...

You'll have to set the api version if you aren't using the latest server. You can use either docker.Client(version='1.20') or docker.Client(version='auto')

Sir, you saved my day. Thank you a lot.

I didnt knew about the version parameter when using the Client... sry

I feel like that auto should be the default since this comes up so often.

@TomasTomecek That would involve making an extra call to the Docker API on every docker-compose command, which is probably unacceptable.

docker-compose would just have to not use the default, so I don't think it's too much of an issue in that respect (given we handle the version bump properly etc).

Fixed default is just much easier to debug than 'auto' in my opinion though.

Fair points.

How about improving the exception message then? Something like:

You have requested daemon API version 1.21 but it supports only 1.20.
Either supply exact version to Client `Client(version="1.20")` or let
client pick it automatically: `Client(version="auto")`

@TomasTomecek That's a great idea. This exception message would help many.

+1

For later versions of docker-py (2.2.1+), you would need to do this

client = docker.DockerClient(version='1.20')

Was this page helpful?
0 / 5 - 0 ratings