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閱讀 228,606評論 6 533
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,582評論 3 418
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,540評論 0 376
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,028評論 1 314
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,801評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,223評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,294評論 3 442
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,442評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,976評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,800評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,996評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,543評論 5 360
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,233評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,662評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,926評論 1 286
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,702評論 3 392
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,991評論 2 374

推薦閱讀更多精彩內容