以下原文轉載于(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.

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.

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.

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。)