Mac平臺(tái)Parallels Desktop結(jié)合Docker安裝入門

目標(biāo)

充分利用Parallels Desktop 虛擬管理平臺(tái),在mac 電腦上安裝好Docker,能正常運(yùn)行,使用Mac簡(jiǎn)潔。

條件

  1. brew 如果還沒(méi)安裝,請(qǐng)參考Mac下安裝brew
  2. Parallels Desktop 11.0.0+ Pro or Business edition(標(biāo)準(zhǔn)版不支持)

安裝過(guò)程

  1. 安裝

1.1 使用brew命令安裝方法

brew install docker-machine-parallels

此過(guò)程會(huì)自動(dòng)安裝 docker-machine命令

1.2 或者:直接下載 docker-machine-driver-parallels 放到$PATH中。
命令

$curl -L https://github.com/Parallels/docker-machine-parallels/releases/download/v1.4.0/docker-machine-driver-parallels > /usr/local/bin/docker-machine-driver-parallels
$chmod +x /usr/local/bin/docker-machine-driver-parallels
$brew install docker-machine

國(guó)內(nèi)用戶下載詳見(jiàn)文章最后網(wǎng)盤

  1. Mac 安裝 Docker客戶端
brew install docker
  1. 創(chuàng)建book2docker虛擬機(jī)
docker-machine create --driver=parallels prl-dev

其中 prl-dev 為虛擬機(jī)名字,可以自定義

輸出參考:
docker-machine create --driver=parallels prl-dev

Creating CA: /Users/xxx/.docker/machine/certs/ca.pem
Creating client certificate: /Users/xxx/.docker/machine/certs/cert.pem
Running pre-create checks...
(prl-dev) Image cache directory does not exist, creating it at /Users/xxx/.docker/machine/cache...
(prl-dev) No default Boot2Docker ISO found locally, downloading the latest release...
(prl-dev) Latest release for github.com/boot2docker/boot2docker is v19.03.5
(prl-dev) Downloading /Users/xxx/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.5/boot2docker.iso...
(prl-dev) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(prl-dev) Copying /Users/xxx/.docker/machine/cache/boot2docker.iso to /Users/xxx/.docker/machine/machines/prl-dev/boot2docker.iso...
(prl-dev) Creating SSH key...
(prl-dev) Creating Parallels Desktop VM...
(prl-dev) Starting Parallels Desktop VM...
(prl-dev) Waiting for VM to come online...
(prl-dev) Mounting shared folder "/Users" ...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
當(dāng)出現(xiàn)Docker is up and running 表示成功。

如果boot2docker.iso無(wú)法下載,請(qǐng)自行下載到/Users/xxx/.docker/machine/machines/prl-dev/【xxx為自己的mac帳號(hào),請(qǐng)自行更改,prl-dev為虛擬機(jī)名字,如果不同,請(qǐng)自行更改】,下載地址:https://github.com/boot2docker/boot2docker/releases
國(guó)內(nèi)用戶下載詳見(jiàn)文章最后網(wǎng)盤。

  1. Docker 綁定虛擬機(jī)
docker-machine env prl-dev
eval $(docker-machine env prl-dev)

如有需要,可以增加
eval $(docker-machine env prl-dev)
到你的bash環(huán)境中。

  1. 查看 docker
docker verion

輸出參考:
docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.13.4
Git commit: 633a0ea
Built: Thu Nov 14 23:51:40 2019
OS/Arch: darwin/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea838
Built: Wed Nov 13 07:28:45 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683

  1. 運(yùn)行hellow world
 docker run hello-world

參考輸出:
docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

至此Docker 安裝完成。

總結(jié)

不少用戶Mac 電腦安裝了 Parallels Desktop 虛擬機(jī)管理平臺(tái),而Docker程序由于基于Linux內(nèi)核開(kāi)發(fā),其服務(wù)器端并不能在Mac下直接運(yùn)行。開(kāi)源程序docker-machine-parallels為docker-machine插件,使得Mac用戶利用Parallels Desktop優(yōu)秀的虛擬化技術(shù)為docker服務(wù)。

安裝完成之后,Parallels Desktop 會(huì)多出一個(gè) prl-dev 虛擬機(jī),請(qǐng)勿刪除。

資源網(wǎng)盤

鏈接: https://pan.baidu.com/s/1y5EABosMkWuJh8Y3o_vijg 提取碼: srj3

附錄

定制虛擬機(jī)參考:
To create a Parallels Desktop virtual machine for Docker purposes just run this command:

$ docker-machine create --driver=parallels prl-dev

Available options:

  • --parallels-boot2docker-url: The URL of the boot2docker image.
  • --parallels-disk-size: Size of disk for the host VM (in MB).
  • --parallels-memory: Size of memory for the host VM (in MB).
  • --parallels-cpu-count: Number of CPUs to use to create the VM (-1 to use the number of CPUs available).
  • --parallels-video-size: Size of video memory for host (in MB).
  • --parallels-share-folder: Path to the directory which should be shared with the host VM. Could be specified multiple times, once per each directory.
  • --parallels-no-share: Disable the sharing of any directory.
  • --parallels-nested-virutalization: Enable nested virtualization.

The --parallels-boot2docker-url flag takes a few different forms. By default, if no value is specified for this flag, Machine will check locally for a boot2docker ISO. If one is found, that will be used as the ISO for the created machine. If one is not found, the latest ISO release available on boot2docker/boot2docker will be downloaded and stored locally for future use.

This is the default behavior (when --parallels-boot2docker-url=""), but the option also supports specifying ISOs by the http:// and file:// protocols.

Environment variables and default values:

CLI option Environment variable Default
--parallels-boot2docker-url PARALLELS_BOOT2DOCKER_URL Latest boot2docker url
--parallels-cpu-count PARALLELS_CPU_COUNT 1
--parallels-disk-size PARALLELS_DISK_SIZE 20000
--parallels-memory PARALLELS_MEMORY_SIZE 1024
--parallels-video-size PARALLELS_VIDEO_SIZE 64
--parallels-share-folder - /Users
--parallels-no-share - false
--parallels-nested-virtualization - false
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容