Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple docker clients on the same machine

As I'm working with docker and docker-machine a lot, I have to work with several docker versions at the same time. And we all know how hard this can be:

$ docker ps
Error response from daemon: client is newer than server (client API version: 1.23, server API version: 1.22)

So, my question: (How) is it possible to run multiple versions of docker client on my Ubuntu 16.04? Ideally it would be to automatically select the right version, once I enter a host with docker-machine.

Side note: I know how to update the client or the server. But I still have to work with different versions.

like image 892
Ich Avatar asked Oct 19 '22 08:10

Ich


1 Answers

I found a solution for me:

mkdir /opt/docker && cd /opt/docker
wget https://get.docker.com/builds/Linux/i386/docker-1.11.2.tgz
wget https://get.docker.com/builds/Linux/i386/docker-1.11.0.tgz
wget https://get.docker.com/builds/Linux/i386/docker-1.10.0.tgz # versions you want
tar -xzf docker-1.11.2.tgz -C 1.11.2
tar -xzf docker-1.11.0.tgz -C 1.11.0
tar -xzf docker-1.10.0.tgz -C 1.10.0

add something like this to your .bashrc

PATH_DOCKER=$PATH
dmenter() {
  case $1 in
    swarm)
       eval $(dm env --swarm swarm)
       VERSION=$(docker-machine version swarm)
       export PATH=/opt/docker/$VERSION/usr/local/bin:$PATH_DOCKER
       ;;
    "")
       eval $(docker-machine env --unset)
       export PATH=$PATH_DOCKER
       ;;
    *)
       eval $(docker-machine env $*)
       VERSION=$(docker-machine version $*)
       export PATH=/opt/docker/$VERSION/usr/local/bin:$PATH_DOCKER
       ;;
  esac
}

Now you can enter your docker with dmenter <host> and always have the right client version available.

like image 100
Ich Avatar answered Oct 20 '22 22:10

Ich