ARM Mac における Docker ツールの Virtualization framework 採用状況の続報
ARM Mac において Intel なコンテナイメージを動かすとき、docker コマンドや docker compose では、アーキテクチャを明記することで実現できていた。その裏では QEMU による Intel エミュレーションされるのが一般的であった。
Apple は macOS に Virtualization framework というのを作り込んでいて、macOSアプデ毎に機能拡充されてきている。
で、macOSにおいて Docker コンテナを利用した開発に好都合な、 Virtualization framework のアプデがあり、それを Docker Desktop for Mac と Lima が利用する計画をもってるらしいぞ、というブログ記事が放流され、とてもウキウキした。
2023年になり、ところでどうなったか追ってみた。
Docker Desktop for Mac
2023/01/15 時点最新安定の v4.16 にてBetaサポートまで来たようだ。VirtioFS もそうだけど、 Rosetta 2 によって Intel エミュの高速化も謳われている。遠からず Beta から Stable になるんじゃないでしょうか
finch
AWS が唐突に出してきてザワついたやつ。
finch は v0.2.0 で Lima v0.14.x を取り込んでる
Lima のいくつを使うか finch の go.mod に記載している。
Rancher Desktop
リリースノートからは Lima のいくつをバンドルしてるかパッとは読めなかった。
手元にインストールして確認したところ、最新安定の v1.7.0 では lima v0.13 (にRancher Desktopのパッチを当てた版?)を使っていた。近日を待てって感じなのかな。
❯ pwd
/Applications/Rancher Desktop.app/Contents/Resources/resources/darwin/lima/bin
❯ ./limactl --version
limactl version 0.13.0+rd1
colima
colima は coliima のインストールパッケージに直接 lima をバンドルしておらず、PATH の通ったところにある limactl コマンドを利用してるようだ。つまり homebrew で最新安定の lima を入れていれば、lima 0.14.x で動くようになる。
❯ brew install colima
Running `brew update --auto-update`...
==> Fetching dependencies for colima: capstone, bdw-gc, guile, libtasn1, nettle, p11-kit, libnghttp2, unbound, gnutls, libslirp, libssh, libusb, snappy, vde, qemu and lima
(略)
==> Installing dependencies for colima: capstone, bdw-gc, guile, libtasn1, nettle, p11-kit, libnghttp2, unbound, gnutls, libslirp, libssh, libusb, snappy, vde, qemu and lima
==> Installing colima dependency: capstone
(略)
==> Installing colima dependency: lima
==> Pouring lima--0.14.2.arm64_monterey.bottle.tar.gz
🍺 /opt/homebrew/Cellar/lima/0.14.2: 72 files, 37.7MB
==> Installing colima
==> Pouring colima--0.5.2.arm64_monterey.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/colima/0.5.2: 8 files, 14.2MB
==> Running `brew cleanup colima`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> colima
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
軽くソースを眺めた雰囲気から、PATH の通ったところにある limactl コマンドを利用してるのだろうと理解してます。
❯ ghq get git@github.com:abiosoft/colima.git
clone ssh://git@github.com/abiosoft/colima.git -> /Users/shinnosuke.suzuki/src/github.com/abiosoft/colima
git clone --recursive ssh://git@github.com/abiosoft/colima.git /Users/shinnosuke.suzuki/src/github.com/abiosoft/colima
Cloning into '/Users/shinnosuke.suzuki/src/github.com/abiosoft/colima'...
remote: Enumerating objects: 2899, done.
remote: Counting objects: 100% (258/258), done.
remote: Compressing objects: 100% (139/139), done.
remote: Total 2899 (delta 130), reused 220 (delta 101), pack-reused 2641
Receiving objects: 100% (2899/2899), 2.49 MiB | 2.23 MiB/s, done.
Resolving deltas: 100% (1557/1557), done.
❯ cd ~/src/github.com/abiosoft/colima
❯ rg limactl
environment/vm/lima/limautil/limautil.go
90: cmd := cli.Command("limactl", "show-ssh", "--format", format, profileID)
196: cmd := cli.Command("limactl", "list", profileID, "--json")
213: cmd := cli.Command("limactl", "list", "--json")
257: cmd := cli.Command("limactl", "shell", profileID, "sh", "-c",
268: cmd := cli.Command("limactl", "shell", profileID, "--", "sh", "-c", "echo $"+LayerEnvVar)
310: cmd := cli.Command("limactl", "info")
environment/vm/lima/lima.go
53: limactl = "limactl"
228: return l.host.Run(limactl, "start", "--tty=false", configFile)
269: return l.host.Run(limactl, "start", config.CurrentProfile().ID)
304: return l.host.Run(limactl, "stop", "--force", config.CurrentProfile().ID)
306: return l.host.Run(limactl, "stop", config.CurrentProfile().ID)
322: return l.host.Run(limactl, "delete", "--force", config.CurrentProfile().ID)
360: args = append([]string{limactl, "shell", "--workdir", workingDir, config.CurrentProfile().ID}, args...)
app/app.go
236: // with limactl ssh
Chrome がクラッシュする問題の解決策となってほしいなあ
Intel エミュのエンジンが QEMU ではなく Rosetta 2 になると、高速化されてイイ!!という観点でもちろん歓迎なのですが、それとは別でより完全に近い Intel エミュになるほうに期待してます。というのは、、、
ChromeでE2EテストやらせるとQEMUの不完全なエミュを踏んでChromeがクラッシュしてました。これの回避策は模索が続いており、 gunosy さんが編み出したのが決定版でした。ただこれも大変なもので、チョチョッと真似するのは厳しいものがありました。
Rosetta 2 になることで、Intel エミュが完全に近くなり、Chromeがクラッシュしなくなる、というのを期待してます。
Lima
メモの順番ミスったな...
Lima そのものは、 v0.14.0 で Virtualization framework, VirtioFS, Rosetta 2 対応を果たしたようです。