同一台机器上的多个Docker客户端 [英] multiple docker clients on the same machine

查看:71
本文介绍了同一台机器上的多个Docker客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我经常使用docker和docker-machine,因此必须同时使用多个docker版本.我们都知道这有多难:

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)

所以,我的问题是:(如何)在Ubuntu 16.04上可以运行多个版本的Docker客户端?理想情况下,一旦我使用 docker-machine 输入主机,便会自动选择正确的版本.

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.

推荐答案

我为我找到了解决方案:

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

在您的 .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
}

现在,您可以使用 dmenter< host> 输入docker,并始终拥有正确的客户端版本.

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

这篇关于同一台机器上的多个Docker客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆