はじめに
Lima とはどんなものなのか、どうやって使うのかざっくりまとめてみたいと思います。
Lima とは
Lima(Linux Machines)は、ファイル共有とポートフォワードを自動でやってくれる Linux 仮想マシンを構築してくれるツールです。
![]()
containerd を標準でサポートしており、そのほかのコンテナエンジン(Docker, Podman など)もサポートしています。
そのため、Lima で VM 構築して、その上でコンテナを起動するといったことができます。
インストール
インストールはbrewを使ってできます。
1brew install lima使い方
簡単な使い方を紹介します。
VM の起動
下記のコマンドで VM の起動ができます。--name=[instance name]でインスタンスの名前を設定できます。デフォルトの名前はdefaultです。
1limactl start実行すると、そのままの設定で起動するか、エディタを開いて設定を変更するか、テンプレートを選択するか聞かれますが、Proceed with the current configurationを選択するとそのままの設定で VM の起動が開始されます。
1❯ limactl start
2? Creating an instance "default" [Use arrows to move, type to filter]
3> Proceed with the current configuration
4 Open an editor to review or modify the current configuration
5 Choose another template (docker, podman, archlinux, fedora, ...)
6 Exitテンプレートから起動
テンプレートを選択して、起動する場合は下記になります。
1limactl start template://[template name]1limactl start template://rocky-9テンプレートは下記から選択できます。
Templates
Run limactl start template://fedora to create a Lima instance named "fedora". To open a shell, run limactl shell fedora bash or LIMA_INSTANCE=fedora lima bash. ⭐ = "Tier 1" ☆ = "Tier 2" Default: default (⭐Ubuntu, with containerd/nerdctl) Distro: almalinux-8: AlmaLinux 8 almalinux-9: AlmaLinux 9 almalinux-10, almalinux.yaml: AlmaLinux 10 almalinux-kitten-10, almalinux-kitten.yaml: AlmaLinux Kitten 10 alpine: ☆Alpine Linux alpine-iso: ☆Alpine Linux (ISO9660 image). Compatible with the alpine template used in Lima prior to v1.
設定ファイルから起動
自分で設定ファイルを作成して、その設定から VM を起動することもできます。
1limactl start [yaml file]1limactl start my-vm.yaml設定ファイルの中身はdefaultの設定を参考に作成できます。
VM の一覧
下記で VM の一覧が確認できます。
1limactl list1❯ limactl list
2NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR
3default Running 127.0.0.1:60022 qemu x86_64 4 4GiB 100GiB ~/.lima/defaultコマンドの実行とシェルへの接続
下記のコマンドで対象のインスタンスでコマンドを実行できます。
1limactl shell [instance] [command]また、下記で対象のインスタンスのシェルに接続できます。
1limactl shell [instance]limaコマンドもあり、下記 2 つのコマンドは同じものになります。
1lima
2limactl shell default実際に使ってみる
下記の"Learning eBPF"のサンプルで用意されているlearning-ebpf.yamlを使って、VM を起動してみたいと思います。
learning-ebpf/learning-ebpf.yaml at main · lizrice/learning-ebpf
Learning eBPF, published by O'Reilly - out now! Here's where you'll find a VM config for the examples, and more - lizrice/learning-ebpf
まずは、設定ファイルを使って VM を起動します。
1❯ limactl start learning-ebpf.yaml
2? Creating an instance "learning-ebpf" [Use arrows to move, type to filter]
3> Proceed with the current configuration
4 Open an editor to review or modify the current configuration
5 Choose another template (docker, podman, archlinux, fedora, ...)
6 Exit起動が完了して、limactl listを実行すると起動しているのが確認できます。
1❯ limactl list
2NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR
3learning-ebpf Running 127.0.0.1:58090 qemu x86_64 4 10GiB 100GiB ~/.lima/learning-ebpfシェルに接続してみます。
1❯ limactl shell learning-ebpf
2masa@lima-learning-ebpf:/Users/masa$lsとかを実行すると、ホストマシンのファイルが確認でき、ファイル共有ができていることがわかります。また、ホームディレクトリは VM のユーザーのホームディレクトリになっていることがわかります。
1masa@lima-learning-ebpf:/Users/masa$ echo $HOME
2/home/masa.linuxVM の停止と削除は下記のコマンドでできます。
1limactl stop learning-ebpf1limactl delete learning-ebpf参考
- Lima
- Lima: Linux Machines | Lima
- lima-vm/lima: Linux virtual machines, with a focus on running containers
- lizrice/learning-ebpf: Learning eBPF, published by O'Reilly - out now! Here's where you'll find a VM config for the examples, and more




