概要
limaでnerdctlを試すだけの記事
前提
手元のMacOS Monterey
手順
// インストール
$ brew install lima
// 下記でqemuプロセス等を起動。下記のdefaultはVM名です。
$ limactl start --name=default
// defaultの起動を確認する (psでもみれる)
$ limactl list
NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR
default Running 127.0.0.1:60022 qemu x86_64 4 4GiB 100GiB ~/.lima/default
// nerdctl経由でnginxを起動します
$ lima nerdctl run -d --name nginx -p 8080:80 nginx
$ lima nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
246bdb108cbd docker.io/library/nginx:latest "/docker-entrypoint.…" 27 seconds ago Up 0.0.0.0:8080->80/tcp nginx
// nginxから応答が返ってくることを確認します
$ curl -I localhost:8080
HTTP/1.1 200 OK
Server: nginx/1.27.4
Date: Mon, 24 Feb 2025 04:40:54 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Wed, 05 Feb 2025 11:06:32 GMT
Connection: keep-alive
ETag: "67a34638-267"
Accept-Ranges: bytes
// nginxコンテナを停止します。
$ lima nerdctl stop nginx
nginx
$ lima nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$
// QEMUのプロセスを停止します。
$ limactl stop default
// stopだけだと作成したdefaultは残っています。
$ limactl list
NAME STATUS SSH VMTYPE ARCH CPUS MEMORY DISK DIR
default Stopped 127.0.0.1:0 qemu x86_64 4 4GiB 100GiB ~/.lima/default
// 不要となったVM(default)を削除します
$ limactl delete default
INFO[0000] The qemu driver process seems already stopped
INFO[0000] The host agent process seems already stopped
INFO[0000] Removing *.pid *.sock *.tmp under "/Users/tsuyoshi/.lima/default"
INFO[0000] Removing "/Users/tsuyoshi/.lima/default/ha.sock"
INFO[0000] Deleted "default" ("/Users/tsuyoshi/.lima/default")
// defaultが削除されたことを確認
$ limactl list
WARN[0000] No instance found. Run `limactl create` to create an instance.