跳至主要内容

[Docker] Use docker cli w/o Docker Desktop on macOS

Docker inc 宣布 Docker Desktop 商業使用不再免費, 原本都是個人開發使用, 影響有限, 但後來公司開發需要, 得面對這個問題.

備選方案有:

  1. 付費
  2. 改用 Podman
  3. 改用 docker cli

公司長期方向是走向 Podman, 不過目前還有許多專案 CI/CD 用 docker 建制, 先打通 docker cli 維持專案正確是必要的. 且許多雲端服務目前仍是提供 docker 環境和指令, 無法完全棄用 docker.

It's important to note, the licensing changes only affect the Docker Desktop product, the CLI interface remains free for all users.

紀錄一下在 macOS 上安裝 docker cli 過程.

Install docker

macOS 上可以直接用 homebrew 來安裝 docker.

除了 docker 外, 還需要安裝 docker-credential-helper, credential helper 可以用 macOS Keychain 來儲存遠端 repo credential,

brew install docker docker-credential-helper

上面指令安裝了 docker cli 命令程式, 安裝完成後可以看到有 docker 指令不會 command not found, 但 docker ps 仍找不到相關 daemon.

Install colima

真正重要的是提供 contrainer runtime 的服務, macOS 上可選用目前開源且免費的 Colima

brew install colima

從套件相依性可以看到 colima 是以 qemu 核心建構的虛擬框架, 集成許多 open source 專案提供的 container runtime service.

Using colima

安裝完成後把服務啟動

colima start

第一次啟動時需要下載 qemu 影像檔, 靜待下載安裝即可.

服務正常啟動的狀態

colima services

若想讓 colima 服務常駐, 重新開機後能自動啟動, 可利用 brew services

brew services start colima

See Also

Colima

Colima means Containers in Lima. Since Lima is aka Linux on Mac. By transitivity, Colima can also mean Containers on Linux on Mac.

Colima 額外還支援 Kubernetes 基礎建設, 再另找時間好好研究.

Refs: