Newer docker client with older Docker host
We have a slightly older Docker server running on RHEL 6.6. It's not well-supported by our operations team right now, so we can't upgrade easily. Right now it runs Docker 1.3.2 from an EPEL repo. If I ssh in it does everything that I need for proofs-of-concept that will hopefully help me push management to improve the infrastructure support for Docker down the road.
I set it up to listen on TCP/TLS, and I'm able to connect to it, but it refuses to run commands given by my local docker client.
$ docker version
Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.4
Git commit (client): 5bc2ff8
OS/Arch (client): darwin/amd64
FATA[0000] Error response from daemon: client and server don't have same version (client : 1.16, server: 1.15)
I know the connection itself works because fig
works:
$ cat > fig.yml
test:
image: busybox
$ fig run --rm test sh
/ # hostname -f
084f75fb59d4
Is there some way I can tell the newer docker client to use the older docker API version until I can access to a newer docker host?
Since Docker 1.10.0, there's an option for overriding the API Version used for Docker client communication with Docker engine.
Just by using the DOCKER_API_VERSION environment variable.
Ex.:
$ docker version
Client:
Version: 1.10.0
API version: 1.22
Go version: go1.5.3
Git commit: 590d510
Built: Fri Feb 5 08:21:41 UTC 2016
OS/Arch: darwin/amd64
Error response from daemon: client is newer than server (client API version: 1.22, server API version: 1.21)
$ DOCKER_API_VERSION=1.21 docker version
Client:
Version: 1.10.0
API version: 1.21
Go version: go1.5.3
Git commit: 590d510
Built: Fri Feb 5 08:21:41 UTC 2016
OS/Arch: darwin/amd64
Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: linux/amd64
Reference: https://docs.docker.com/engine/reference/commandline/cli/#environment-variables
EDIT
Since Docker 1.13, CLI has an improved backwards compatibility. According to https://blog.docker.com/2017/01/whats-new-in-docker-1-13 :
Starting with 1.13, newer CLIs can talk to older daemons. We’re also adding feature negotiation so that proper errors are returned if a new client is attempting to use features not supported in an older daemon. This greatly improves interoperability and makes it much simpler to manage Docker installs with different versions from the same machine.
If you cannot easily upgrade the server, you should be able to easily downgrade your client. Docker is open source at GitHub. Version 1.3.3 was the last with the 1.15 client API. Here is a direct link to the tag.
Just make a local clone of the repo, make build, make binary and then swap the produced binary:
sudo service docker stop ; sudo cp $(which docker) $(which docker)_ ; sudo cp ./bundles/1.3.3-dev/binary/docker-1.3.3-dev $(which docker);sudo service docker start