Docker for Mac vs. Docker Toolbox

以下原文转载于(https://docs.docker.com/docker-for-mac/)(想找中文版的最新文档,最后发现还是直接看英文的靠谱。ps:本人英文很渣,以下翻译纯属Google加上一些修改来让我省些时间重新看英文,翻译仍需花时间精改。有问题欢迎评论提出,谢谢0.0)

If you already have an installation of Docker Toolbox, please read these topics first to learn how Docker for Mac and Docker Toolbox differ, and how they can coexist.
(如果你已安装了Docker Toolbox,请先阅读下列标题来学习Docker和Docker Toolbox的不同之处,并且如何使它们共存)

The Docker Toolbox environment
Docker Toolbox installs <code>docker</code>,<code>docker-compose </code>and <code>docker -machine</code> in <code>/usr/local/bin</code> on your Mac. It also installs VirtualBox. At installation time, Toolbox uses <code>docker -machine</code> to provision a VirtualBox VM called <code>default</code>, running the <code>boot2docker</code> Linux distribution, with Docker Engine with certificates located on your Mac at <code>$HOME/.docker/machine/machines/default</code>.
(Docker Toolbox在Mac的<code>/usr/local/bin</code>目录下安装了<code>docker</code>,<code>docker-compose </code>and <code>docker -machine</code>。它也安装了VirtualBox。在安装过程中,Toolbox通过<code>docker -machine</code>命令,使用Docker Engine(其证书位于 <code>$HOME/.docker/machine/machines/default</code>.)来配置了一个名称为<code>default</code>的VirtualBox VM,它运行<code>boot2docker</code>Linux发行版,)

Before you use <code>docker</code> or <code>docker-compose</code> on your Mac, you typically use the command <code>eval $(docker-machine env default)</code> to set environment variables so that <code>docker</code> or <code>docker-compose</code> know how to talk to Docker Engine running on VirtualBox.
(在你使用<code>docker</code>或者<code>docker-compose</code>命令之前,你需要键入命令<code>eval $(docker-machine env default)</code>来设置环境变量来使<code>docker</code>或者<code>docker-compose</code>命令知道如何让Docker Engine运行在VirtualBox上)

This setup is shown in the following diagram.

Docker Toolbox Install
Docker Toolbox Install

The Docker for Mac environment
Docker for Mac is a Mac native application, that you install in <code>/Applications</code>
. At installation time, it creates symlinks in <code>/usr/local/bin</code> for <code>docker</code> and <code>docker-compose</code>, to the version of the commands inside the Mac application bundle, in<code>/Applications/Docker.app/Contents/Resources/bin</code>.
(Docker for Mac是MAC中原生APP,你可以安装在<code>/Applications</code>目录下,安装过程中,它在Mac程序包中为<code>docker</code>和<code>docker-compose</code>创建了与<code>/usr/local/bin</code>的命令行版本的符合链接,)

Here are some key points to know about Docker for Mac before you get started:
(下面是在你启动Docker for Mac前须知的一些关键点:)
Docker for Mac does not use VirtualBox, but rather HyperKit, a lightweight macOS virtualization solution built on top of Hypervisor.framework in macOS 10.10 Yosemite and higher.
(Docker for Mac不使用VirtualBox,而是使用HyperKit,一个轻量级的macOS虚拟化解决方案,它在MacOS 10.10 Yosemite及更高版本中的Hypervisor.framework中编译)

Installing Docker for Mac does not affect machines you created with Docker Machine. The install offers to copy containers and images from your local default machine (if one exists) to the new Docker for Mac HyperKit VM. If chosen, content from default is copied to the new Docker for Mac HyperKit VM, and your original default machine is kept as is.
(安装Docker for Mac不会影响使用Docker Machine创建的machines,安装提供了从你本地默认的machines(如果存在的话)的容器和镜像复制到新的Docker for Mac的HyperKit VM中。如果被选中,内容会被复制到Docker for Mac的HyperKit VM中,而原来默认的machine仍然保持原来样子)

The Docker for Mac application does not use <code>docker-machine</code> to provision that VM; but rather creates and manages it directly.
(Docker for Mac不使用<code>docker-machine</code>来配置VM,但它直接创建和管理它)

At installation time, Docker for Mac provisions an HyperKit VM based on Alpine Linux, running Docker Engine. It exposes the docker API on a socket in <code>/var/run/docker.sock</code>. Since this is the default location where docker will look if no environment variables are set, you can start using <code>docker</code> and <code>docker-compose</code> without setting any environment variables.
(安装过程中,Docker for Mac根据AIpine Linux,运行Docker Engine来配置HyperKit VM,它在<code>/var/run/docker.sock</code>中暴露出docker的API,因此这是docker如果没有设置环境变量下所映射的默认目录。你可以在没有设置任何环境变量的情况下使用<code>docker</code>和<code>docker-compose</code>来启动)

This setup is shown in the following diagram.


Docker for Mac Install
Docker for Mac Install

With Docker for Mac, you get only one VM, and you don’t manage it. It is managed by the Docker for Mac application, which includes autoupdate to update the client and server versions of Docker.
(你通过Docker for Mac仅可换取一个VM,并且你不可以管理它,它是由Docker应用来管理,此应用包含自动更新Docker的客户端和服务端)

If you need several VMs and want to manage the version of the Docker client or server you are using, you can continue to use <code>docker-machine</code>, on the same machine, as described in Docker Toolbox and Docker for Mac coexistence.
(在同一个machine上,如果你需要数个VM,并且想管理你正在使用的Docker的客户端和服务端,你可以继续使用<code>docker-machine</code>,参考Docker Toolbox and Docker for Mac coexistence

Setting up to run Docker for Mac
Check whether Toolbox DOCKER environment variables are set:
(检查Toolbox DOCKER环境变量是否已设置:)
<pre>
$ env | grep
DOCKER DOCKER_HOST=tcp://192.168.99.100:2376 DOCKER_MACHINE_NAME=default
DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=/Users/victoriabialas/.docker/machine/machines/default
</pre>

If this command returns no output, you are ready to use Docker for Mac.
(如果命令没有输出返回,你需要使用Docker for Mac)
If it returns output (as shown in the example), you need to unset the DOCKER environment variables to make the client talk to the Docker for Mac Engine (next step).
(如果它像例子一样返回输出,你需要取消DOCKER的环境变量的设置来让客户端连接上Docker for Mac Engine (next step))

Run the <code>unset</code> command on the following DOCKER environment variables to unset them in the current shell.
(对以下DOCKER环境变量运行<code>unset</code>来让它们在当前的shell中失效)
<pre>
unset DOCKER_TLS_VERIFY
unset DOCKER_CERT_PATH
unset DOCKER_MACHINE_NAME
unset DOCKER_HOST
</pre>

Now, this command should return no output.
(现在,这条命令应该无输出返回)
<pre>
$ env | grep DOCKER
</pre>

If you are using a Bash shell, you can use <code>unset ${!DOCKER_}</code> to unset all DOCKER environment variables at once. (This will not work in other shells such as zsh; you will need to unset each variable individually.)
(如果你正在使用Bash shell,你可以使用<code>unset ${!DOCKER_
}</code>来使DOCKER环境变量马上失效(这在如zsh这些其他的shell中是不起作用的,你可以单独地为每一个变量都设置无效))

Note: If you have a shell script as part of your profile that sets these DOCKER environment variables automatically each time you open a command window, then you will need to unset these each time you want to use Docker for Mac.
提示:如果你有一个shell脚本作为你配置文件中的一部分,每次你一打开命令行窗口时都会自动设置这些环境变量,那么你每次想使用Docker for Mac时需要unset这些环境变量)

Warning: If you install Docker for Mac on a machine where Docker Toolbox is installed, it will replace the docker and <code>docker-compose</code> command lines in /usr/local/bin with symlinks to its own versions.
Warning:如果你在一个已安装Docker Toolbox的机器上再安装Docker for Mac,它会覆盖docker并且<code>docker-compose</code>命令会链接到它自己版本的<code>/usr/local/bin</code>中)

Docker Toolbox and Docker for Mac coexistence
You can use Docker for Mac and Docker Toolbox together on the same machine. When you want to use Docker for Mac, make sure all DOCKER environment variables are unset. You can do this in bash with <code>unset ${!DOCKER_}</code>. When you want to use one of the VirtualBox VMs you have set with <code>docker-machine</code>, just run a <code>eval $(docker-machine env default)</code> (or the name of the machine you want to target). This will switch the current command shell to talk to the specified Toolbox machine.
(你可以在同一台机器上使用Docker for Mac和Docker Toolbox。当你想要使用Docker for Mac,确保所有的DOCKER环境变量失效,你可以使用<code>unset ${!DOCKER_
}</code>来实现。当你想要使用其中一个VirtualBox VMs时,你需要使用<code>docker-machine</code>,只需要运行<code>eval $(docker-machine env default)</code>即可(或者你想要指定的目标的名称)。这会根据当前的命令来选择特定的Toolbox machine)

This setup is represented in the following diagram.


Docker Toolbox and Docker for Mac coexistence
Docker Toolbox and Docker for Mac coexistence

Using different versions of Docker tools
The coexistence setup works as is as long as your VirtualBox VMs provisioned with docker-machine run the same version of Docker Engine as Docker for Mac. If you need to use VMs running older versions of Docker Engine, you can use a tool like Docker Version Manager to manage several versions of docker client.
(运行的Docker Engine和Docker for Mac版本相同,只要使用VirtualBox VMs使用<code>docker-machine</code>来进行配置,就可以共存并正常工作。如果你需要使用VMs运行更旧版本的Docker Engine,你需要Docker Version Manager这样的工具来管理不同版本的docker客户端)

Checking component versions
Ideally, the Docker CLI client and Docker Engine should be the same version. Mismatches between client and server, and among host machines you might have created with Docker Machine can cause problems (client can’t talk to the server or host machines).
(理想情况下,Docker CLI客户端和Docker Engine应该保持版本相同。客户端和服务端之间以及你使用Docker Machine创建的主机之间存在的不匹配可能会导致问题(客户端无法与服务端或者主机进行通信))

If you already have Docker Toolbox installed, and then install Docker for Mac, you might get a newer version of the Docker client. Run <code>docker version</code> in a command shell to see client and server versions. In this example, the client installed with Docker for Mac is Version: 1.11.1
and the server (which was installed earlier with Toolbox) is Version: 1.11.0.
(如果你已经安装了Docker Toolbox,然后又安装了Docker for Mac,你可能想获取一个更新版本的Docker客户端,在命令行shell中运行<code>docker version</code>来查看客户端和服务端的版本。在这个例子中,Docker for Mac中的客户端版本为1.11.1)
<pre>
$ docker versionClient:Version: 1.11.1...Server:Version: 1.11.0...
</pre>

Also, if you created machines with Docker Machine (installed with Toolbox) then upgraded or installed Docker for Mac, you might have machines running different versions of Engine. Run <code>docker-machine ls</code> to view version information for the machines you created. In this example, the DOCKER column shows that each machine is running a different version of server.
(此外,如果你使用Toolbox安装的Docker Machine来创建machines,然后升级或安装Docker for Mac,你可能会存在运行着不同版本的Engine的machines,使用<code>docker-machine ls</code>来查看你创建的machines的版本信息,在这个例子中,DOCKER列会显示每一个machine正在运行不同版本的服务)
<pre>
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
aws-sandbox - amazonec2 Running tcp://52.90.113.128:2376 v1.1
0.0
default * virtualbox Running tcp://192.168.99.100:2376 v1.1
0.1
docker-sandbox - digitalocean Running tcp://104.131.43.236:2376 v1.1
0.0
</pre>

You might also run into a similar situation with Docker Universal Control Plan (UCP).
(你也可能遇到类似的情况与Docker通用控制计划(UCP)。)

There are a few ways to address this problem and keep using your older machines. One solution is to use a version manager like DVM.
(有几种方法来解决这个问题并继续使用旧机器。 一个解决方案是使用像DVM的版本管理器。)

How do I uninstall Docker Toolbox?
You might decide that you do not need Toolbox now that you have Docker for Mac, and want to uninstall it. For details on how to perform a clean uninstall of Toolbox on the Mac, see How to uninstall Toolbox in the Toolbox Mac topics.
(你可能会认为你现在不需要Toolbox,你有Docker for Mac,并想要卸载它。 有关如何在Mac上执行干净卸载Toolbox的详细信息,请参阅如何在Toolbox Mac主题中卸载Toolbox。)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容