Colimaにてhost agent is running but driver is notとエラーが出たので対処した時の記録

Docker Desktop for Macが有償となってからDockerを直接使っていましたが、もうちょっとシンプルに扱いたいと思いcolimaにトライしていました。その際出くわしたエラーの対処記録です。
2023.02.13

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Docker Desktop for Macの有料化後、直接dockerを使っていましたがコマンドの手続き等で面倒に感じていました。最近は色々と選択肢も出ています。そこで変えるのも一つの手とcolimaを試してみました。

セットアップ

ソースコードからのビルドは依存ライブラリのビルドを含めると長丁場となりそうだったため、今回はhomebrewを利用しました。

brew install colima
colima start

トラブルシュート

ログに以下の出力がでて実行できなくなった場合はステータスを確認しましょう。

Using the existing instance "colima"
errors inspecting instance: [host agent is running but driver is not]

% colima ls
PROFILE    STATUS     ARCH       CPUS    MEMORY    DISK     RUNTIME    ADDRESS

STATUSがBrokenとなっていた場合はやり直しとなりますが、その際はログからダウンロードしているイメージのURLを確認しましょう。アーキテクチャが一致していない場合は何度やってもベースとなっているlimaの方で失敗してBrokenとなります。

x86-64のイメージをarm64にてビルドしようとして失敗していた、というケース前提にて以下対処例。

$ cat >> 'EOF' < focal-amd64.yaml
arch: "x86_64"
images:
- location: "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
  arch: "x86_64"
EOF

設定ファイルのチェックを行い、問題なければ再度実行します。

$ limactl validate focal-amd64.yaml
INFO[0000] "focal-amd64.yaml": OK
% limactl start --tty=false focal-amd64.yaml
INFO[0000] Terminal is not available, proceeding without opening an editor
INFO[0000] Attempting to download the image from "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"  digest=
615.88 MiB / 615.88 MiB [-----------------------------------] 100.00% 2.07 MiB/s
INFO[0299] Downloaded the image from "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
INFO[0303] Attempting to download the nerdctl archive from "https://github.com/containerd/nerdctl/releases/download/v1.1.0/nerdctl-full-1.1.0-linux-amd64.tar.gz"  digest="sha256:5440c7b3af63df2ad2c98e185e06a27b4a21eea334b05408e84f8502251d9459"
INFO[0303] Using cache "/Users/XXXXXXXXXXXXXX/Library/Caches/lima/download/by-url-sha256/dabf40bf0b785bdfa60d957219520047fd7f68de336c973b22796a9aa1dcf1f6/data"
INFO[0307] [hostagent] Starting QEMU (hint: to watch the boot progress, see "/Users/XXXXXXXXXXXXX/.lima/focal-amd64/serial.log")
INFO[0307] SSH Local Port: 50984
INFO[0307] [hostagent] Waiting for the essential requirement 1 of 3: "ssh"
INFO[0317] [hostagent] Waiting for the essential requirement 1 of 3: "ssh"
INFO[0346] [hostagent] Waiting for the essential requirement 1 of 3: "ssh"
INFO[0350] [hostagent] The essential requirement 1 of 3 is satisfied
INFO[0350] [hostagent] Waiting for the essential requirement 2 of 3: "user session is ready for ssh"
INFO[0373] [hostagent] Waiting for the essential requirement 2 of 3: "user session is ready for ssh"
INFO[0377] [hostagent] The essential requirement 2 of 3 is satisfied
INFO[0377] [hostagent] Waiting for the essential requirement 3 of 3: "the guest agent to be running"
INFO[0377] [hostagent] The essential requirement 3 of 3 is satisfied
INFO[0377] [hostagent] Waiting for the optional requirement 1 of 2: "systemd must be available"
INFO[0377] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/Users/XXXXXXXXXXX/.lima/focal-amd64/ga.sock" (host)
INFO[0377] [hostagent] The optional requirement 1 of 2 is satisfied
INFO[0377] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed"
INFO[0377] [hostagent] Not forwarding TCP 127.0.0.53:53
INFO[0377] [hostagent] Not forwarding TCP 0.0.0.0:22
INFO[0377] [hostagent] Not forwarding TCP [::]:22
INFO[0417] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed"
INFO[0457] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed"
INFO[0478] [hostagent] The optional requirement 2 of 2 is satisfied
INFO[0478] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished"
INFO[0496] [hostagent] The final requirement 1 of 1 is satisfied
INFO[0496] READY. Run `limactl shell focal-amd64` to open the shell.

問題なく行った場合は改めてcolimaにてやり直しておきます。というのも、limaのイメージ管理とcolimaのイメージ管理は同一ではありません。limaからの継承はサポート対象外です。

Are Lima overrides supported?
Yes, however this should only be done by advanced users.
Overriding the image is not supported as Colima's image includes bundled dependencies that would be missing in the user specified image.

colimaとlimaの夫々でのイメージ管理は以下のキャプチャを見るとわかりやすいかもしれません。この場合、colimaではfocal-amd64のイメージは取り扱えない状態です。

あとがき

dockerよりも扱いはシンプルですが、エラーメッセージが即ち原因を示しているとは限らないため、若干の慣れは必要かもしれません。また、ターミナル上での操作を優先したためにGUIではありません。グラフィカルなUIが必要な場合はRancher Desktopがおすすめでしょう。

参考