以下原文轉(zhuǎn)載于(https://docs.docker.com/docker-for-mac/)(想找中文版的最新文檔,最后發(fā)現(xiàn)還是直接看英文的靠譜。ps:本人英文很渣,以下翻譯純屬Google加上一些修改來讓我省些時(shí)間重新看英文,翻譯仍需花時(shí)間精改。有問題歡迎評(píng)論提出,謝謝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,請(qǐng)先閱讀下列標(biāo)題來學(xué)習(xí)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>.)來配置了一個(gè)名稱為<code>default</code>的VirtualBox VM,它運(yùn)行<code>boot2docker</code>Linux發(fā)行版,)
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>來設(shè)置環(huán)境變量來使<code>docker</code>或者<code>docker-compose</code>命令知道如何讓Docker Engine運(yùn)行在VirtualBox上)
This setup is shown in the following diagram.

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>創(chuàng)建了與<code>/usr/local/bin</code>的命令行版本的符合鏈接,)
Here are some key points to know about Docker for Mac before you get started:
(下面是在你啟動(dòng)Docker for Mac前須知的一些關(guān)鍵點(diǎn):)
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,一個(gè)輕量級(jí)的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不會(huì)影響使用Docker Machine創(chuàng)建的machines,安裝提供了從你本地默認(rèn)的machines(如果存在的話)的容器和鏡像復(fù)制到新的Docker for Mac的HyperKit VM中。如果被選中,內(nèi)容會(huì)被復(fù)制到Docker for Mac的HyperKit VM中,而原來默認(rèn)的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,但它直接創(chuàng)建和管理它)
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根據(jù)AIpine Linux,運(yùn)行Docker Engine來配置HyperKit VM,它在<code>/var/run/docker.sock</code>中暴露出docker的API,因此這是docker如果沒有設(shè)置環(huán)境變量下所映射的默認(rèn)目錄。你可以在沒有設(shè)置任何環(huán)境變量的情況下使用<code>docker</code>和<code>docker-compose</code>來啟動(dòng))
This setup is shown in the following diagram.

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僅可換取一個(gè)VM,并且你不可以管理它,它是由Docker應(yīng)用來管理,此應(yīng)用包含自動(dòng)更新Docker的客戶端和服務(wù)端)
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.
(在同一個(gè)machine上,如果你需要數(shù)個(gè)VM,并且想管理你正在使用的Docker的客戶端和服務(wù)端,你可以繼續(xù)使用<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環(huán)境變量是否已設(shè)置:)
<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的環(huán)境變量的設(shè)置來讓客戶端連接上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.
(對(duì)以下DOCKER環(huán)境變量運(yùn)行<code>unset</code>來讓它們在當(dāng)前的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.
(現(xiàn)在,這條命令應(yīng)該無輸出返回)
<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環(huán)境變量馬上失效(這在如zsh這些其他的shell中是不起作用的,你可以單獨(dú)地為每一個(gè)變量都設(shè)置無效))
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.
(提示:如果你有一個(gè)shell腳本作為你配置文件中的一部分,每次你一打開命令行窗口時(shí)都會(huì)自動(dòng)設(shè)置這些環(huán)境變量,那么你每次想使用Docker for Mac時(shí)需要unset這些環(huán)境變量)
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:如果你在一個(gè)已安裝Docker Toolbox的機(jī)器上再安裝Docker for Mac,它會(huì)覆蓋docker并且<code>docker-compose</code>命令會(huì)鏈接到它自己版本的<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.
(你可以在同一臺(tái)機(jī)器上使用Docker for Mac和Docker Toolbox。當(dāng)你想要使用Docker for Mac,確保所有的DOCKER環(huán)境變量失效,你可以使用<code>unset ${!DOCKER_}</code>來實(shí)現(xiàn)。當(dāng)你想要使用其中一個(gè)VirtualBox VMs時(shí),你需要使用<code>docker-machine</code>,只需要運(yùn)行<code>eval $(docker-machine env default)</code>即可(或者你想要指定的目標(biāo)的名稱)。這會(huì)根據(jù)當(dāng)前的命令來選擇特定的Toolbox machine)
This setup is represented in the following diagram.

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.
(運(yùn)行的Docker Engine和Docker for Mac版本相同,只要使用VirtualBox VMs使用<code>docker-machine</code>來進(jìn)行配置,就可以共存并正常工作。如果你需要使用VMs運(yùn)行更舊版本的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應(yīng)該保持版本相同。客戶端和服務(wù)端之間以及你使用Docker Machine創(chuàng)建的主機(jī)之間存在的不匹配可能會(huì)導(dǎo)致問題(客戶端無法與服務(wù)端或者主機(jī)進(jìn)行通信))
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.
(如果你已經(jīng)安裝了Docker Toolbox,然后又安裝了Docker for Mac,你可能想獲取一個(gè)更新版本的Docker客戶端,在命令行shell中運(yùn)行<code>docker version</code>來查看客戶端和服務(wù)端的版本。在這個(gè)例子中,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來創(chuàng)建machines,然后升級(jí)或安裝Docker for Mac,你可能會(huì)存在運(yùn)行著不同版本的Engine的machines,使用<code>docker-machine ls</code>來查看你創(chuàng)建的machines的版本信息,在這個(gè)例子中,DOCKER列會(huì)顯示每一個(gè)machine正在運(yùn)行不同版本的服務(wù))
<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通用控制計(jì)劃(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.
(有幾種方法來解決這個(gè)問題并繼續(xù)使用舊機(jī)器。 一個(gè)解決方案是使用像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.
(你可能會(huì)認(rèn)為你現(xiàn)在不需要Toolbox,你有Docker for Mac,并想要卸載它。 有關(guān)如何在Mac上執(zhí)行干凈卸載Toolbox的詳細(xì)信息,請(qǐng)參閱如何在Toolbox Mac主題中卸載Toolbox。)