Quantcast
Channel: 小惡魔 – 電腦技術 – 工作筆記 – AppleBOY
Viewing all articles
Browse latest Browse all 325

在 MAC OS 快速又簡單安裝 Docker 環境 – dlite

$
0
0

Go-brown-side.sh

Mac OS X 底下安裝 Docker 服務不難,只需要到 Docker Mac 教學網站下載 Docker Toolbox,就可以使用 docker-machine, docker, docker-compose 等指令操作 Docker 服務。本篇提供另外一種工具,讓 Mac 開發者可以快速使用 Docker 服務,就是這套用 Go 語言寫的 dlite 工具。

安裝方式

dlite 提供三種方式安裝

  1. 直接下載執行檔案 (推薦) (下載連結)
  2. 直接透過 brew 指令安裝: brew install dlite
  3. 開發者模式: git clone 專案,然後下 make dlite 產生執行檔案

請大家直接使用第一種方式安裝即可。

使用方式

安裝 dlite 需要使用到磁碟空間及記憶體,你可以動態指定 memory 使用量,或者是磁碟空間,詳細指令可以透過 dlite install -h 觀看

$ sudo dlite install -h
Usage:
  dlite [OPTIONS] install [install-OPTIONS]

creates an empty disk image, downloads the os, saves configuration and creates a launchd agent

Help Options:
  -h, --help            Show this help message

[install command options]
      -c, --cpus=       number of CPUs to allocate (default: 1)
      -d, --disk=       size of disk in GiB to create (default: 20)
      -m, --memory=     amount of memory in GiB to allocate (default: 2)
      -s, --ssh-key=    path to public ssh key (default: $HOME/.ssh/id_rsa.pub)
      -v, --os-version= version of DhyveOS to install
      -n, --hostname=   hostname to use for vm (default: local.docker)
      -S, --share=      directory to export from NFS (default: /Users)

可以看到指令預設會佔用 20GB 的磁碟使用量及 2GB 的記憶體,所以安裝時可以調整成個人需求大小,安裝請用 root 使用者

$ sudo dlite install -d 10
Building disk image: done
Downloading OS: done
Writing configuration: done
Creating launchd agent: done

完成後請啟動 dlite 服務

$ dlite start

這邊要提醒執行上述指令後,請大約等 10 ~ 20 秒,再用 docker ps 來確認是否有成功,啟動後可以透過 ssh docker@local.docker 連到 Docker VM。可以在 /etc/hosts 看到

192.168.64.8 local.docker # added by dlite

關閉 VM 服務可以使用 stop 指令

$ dlite stop

如果沒有要用 Docker 了,請切換到 root 直接 uninstall 即可

$ sudo dlite uninstall

移除後會清空 /etc/hosts 內新增的 row,但是沒有清除 /etc/exports 內的資料,於是發了 PR 給作者 remove export command

評語

dlite 安裝起來真的很方便,但是我實際拿了 go-hello 專案來跑測試,結果 go server 竟然跑不起來,真是蠻神奇的,只是個簡單的 Hello world server。本來我還以為是不是 Docker 版本有問題,所以又用 Travis CI 跑了一次結果也沒問題。結論還是要裝官方提供的 Tool Box 比較穩定。


Viewing all articles
Browse latest Browse all 325

Trending Articles


Girasoles para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Tagalog Quotes About Crush – Tagalog Love Quotes


OFW quotes : Pinoy Tagalog Quotes


Long Distance Relationship Tagalog Love Quotes


Tagalog Quotes To Move on and More Love Love Love Quotes


5 Tagalog Relationship Rules


Best Crush Tagalog Quotes And Sayings 2017


Re:Mutton Pies (lleechef)


FORECLOSURE OF REAL ESTATE MORTGAGE


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Patama Quotes : Tagalog Inspirational Quotes


Pamatay na Banat and Mga Patama Love Quotes


Tagalog Long Distance Relationship Love Quotes


BARKADA TAGALOG QUOTES


“BAHAY KUBO HUGOT”


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.