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

Use a Docker client on RHEL?

@MichaelHampton The developers connecting to this docker box are on various Windows and OS X workstations. They tend to have boot2docker installed and would like to use the same docker client pointed at this host.

The ideal choice, then, is to use a Linux distribution which tracks the latest Docker version. At the moment, that’s Fedora Server.

I’m guessing that you would like the Operation guys to upgrade to RHEL 7, which currently appears to be 1.2, and will increment (as it is in the Extras channel, so can grow faster than the Core). If your Ops team can’t support a RHEL 7 (with Red Hat’s paid support), then they certainly can’t support something more bleeding edge such as Fedora. Your developers just need to accept that they need to code to a standard operating environment. See also https://access.redhat.com/solutions/1408853 “How is Docker supported in RHEL 7.1?”