روی macOS، Linux container native اجرا نمیشود — kernel Linux ندارید. راههای classic:
- Docker Desktop — سنگین، licensing، VM opaque
- Multipass / UTM — VM generic بدون container integration
- SSH به remote Linux — latency و setup
Lima ( LInux MAc ) راه سوم است:
Linux virtual machines, with a focus on running containers.
یعنی VM لینوکس با file sharing خودکار، port forwarding، و containerd/nerdctl built-in — شبیه WSL2 اما برای Mac (و Linux host).
پروژه می ۲۰۲۱ توسط Akihiro Suda ساخته شد — هدف اولیه: promote containerd و nerdctl به Mac users. امروز ۲۱K+ GitHub stars، CNCF Incubating (اکتبر ۲۰۲۵).
مشکل container روی macOS
macOS (Darwin kernel)
│
✗ runc/containerd native
✗ Linux cgroups/namespaces مستقیم
│
▼ نیاز به Linux VM
Docker Desktop → hidden VM (licensing)
Lima → open-source, YAML-configurable VM| مشکل | Docker Desktop | Lima |
|---|---|---|
| Open source | client OSS، engine mixed | Apache 2.0 |
| Transparency | black box VM | lima.yaml declarative |
| Runtime choice | Moby fixed | containerd، Docker، k8s template |
| Hypervisor | hidden | QEMU یا Apple VZ |
| Cost | enterprise license | free |
| Kubernetes local | kind in VM | template:k8s |
Lima چیست؟
Lima CLI برای launch Linux VM با:
- Automatic file sharing — edit روی host، build در guest
- Automatic port forwarding —
localhost:8080→ VM - Built-in containerd + nerdctl — default template
- Multi-arch — ARM↔Intel cross emulation
- Guest OS — Ubuntu (default)، Fedora، Alpine، Debian، Arch، …
- Host OS — macOS، Linux، NetBSD (experimental: Windows guest)
Site: lima-vm.io
Docs: lima-vm.io/docs
Latest: v2.1.x (۲۰۲۶)
معماری
نمای کلی
┌─────────────────────────────────────────────────┐
│ macOS / Linux Host │
│ ┌─────────────┐ SSH/socket ┌───────────┐ │
│ │ limactl │◄────────────────►│ hostagent │ │
│ │ lima CLI │ └─────┬─────┘ │
│ └─────────────┘ │ │
│ │ QEMU / VZ │
│ │ ┌────────▼────────┐│
│ ~/project ──virtiofs/9p──► │ Linux Guest VM ││
│ localhost:8080 ◄─forward──► │ Ubuntu/Fedora ││
│ │ containerd ││
│ │ nerdctl/docker ││
│ └─────────────────┘│
└─────────────────────────────────────────────────┘اجزا
| Component | نقش |
|---|---|
| limactl | create/start/stop/delete VM instances |
| lima | shorthand — run command in default VM |
| hostagent | port forward، mount، lifecycle روی host |
| guest agent | coordination داخل VM |
| QEMU / vz | hypervisor backend |
| ~/.lima/ | VM disks، config، logs، sockets |
Hypervisor backends
| Backend | Platform | Notes |
|---|---|---|
| vz | macOS ≥13 (Apple Silicon/Intel) | Virtualization.framework — سریعتر |
| QEMU | macOS، Linux، Windows | cross-arch، compatible |
| WHPX | Windows host | Hyper-V |
| KVM | Linux host | native acceleration |
# Apple VZ (توصیه macOS)
limactl start --vm-type=vz
# QEMU (compatibility)
limactl start --vm-type=qemuنصب و شروع
macOS (Homebrew)
brew install lima
limactl startDefault instance: Ubuntu + containerd + nerdctl.
# Linux command در VM
lima uname -a
# container با nerdctl
lima nerdctl run --rm hello-worldLinux host
# از release binary یا package manager
limactl startروی Linux host از KVM برای acceleration استفاده میشود.
Templates
از templates — prebuilt YAML:
| Template | محتوا |
|---|---|
| default | Ubuntu + containerd + nerdctl ⭐ |
| docker | Docker Engine + compose |
| k8s | Kubernetes (k3s/kubeadm variant) |
| fedora | Fedora Linux |
| alpine | Alpine minimal |
| debian | Debian |
| archlinux | Arch |
| ubuntu | Ubuntu plain |
# Docker-compatible
limactl start template:docker
export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
docker run --rm hello-world
# Kubernetes local
limactl start template:k8s
export KUBECONFIG=$(limactl list k8s --format '{{.Dir}}/copied-from-guest/kubeconfig.yaml')
kubectl get nodeslimactl start template:fedora
limactl shell fedora bashlima.yaml — Configuration
هر instance یک lima.yaml در ~/.lima/<name>/:
# excerpt — conceptual
images:
- location: "https://cloud-images.ubuntu.com/..."
arch: "aarch64"
cpus: 4
memory: "4GiB"
disk: "100GiB"
mounts:
- location: "~"
writable: false
- location: "/tmp/lima"
writable: true
vmType: "vz" # or "qemu"
mountType: "virtiofs" # or "9p", "reverse-sshfs"
portForwards:
- guestPort: 8080
hostPort: 8080
containerd:
system: true
user: true# custom instance
limactl create --name=dev --set=.cpus=8 template:default
limactl start devcontainerd و nerdctl
Default template containerd + nerdctl نصب میکند:
lima nerdctl ps
lima nerdctl pull nginx:alpine
lima nerdctl run -d -p 8080:80 nginx:alpine
curl localhost:8080 # port forward automaticRootless nerdctl — optional در config.
برای workflow شبیه Docker:
alias docker='lima nerdctl'
# یا docker-compat pluginFile Sharing
| Mount type | Notes |
|---|---|
| virtiofs | default روی VZ — سریع |
| 9p | QEMU-compatible |
| reverse-sshfs | fallback |
Home directory معمولاً read-only mount — project folder را writable mount کنید:
mounts:
- location: "~/Projects/myapp"
writable: trueEdit روی Mac → lima nerdctl build در همان path داخل VM.
Port Forwarding
hostagent بهصورت automatic portهای guest را به localhost forward میکند:
lima nerdctl run -d -p 3000:3000 myapp
# localhost:3000 روی Mac کار میکندStatic forward در lima.yaml:
portForwards:
- guestPort: 6443
hostPort: 6443
proto: tcpMulti-Architecture
Lima cross-arch پشتیبانی میکند:
| Host | Guest | Use case |
|---|---|---|
| Apple Silicon (ARM) | ARM | native — سریع |
| Apple Silicon | x86_64 | build Intel images |
| Intel Mac | ARM | test ARM containers |
| Intel Mac | x86_64 | native |
limactl create --arch=x86_64 template:defaultAdopters — Ecosystem
Lima engine زیر hood بسیاری از toolهای desktop است:
| Project | نقش |
|---|---|
| Colima | Docker + k8s با minimal setup |
| Rancher Desktop | GUI — k8s + container management |
| Finch | AWS — local container dev |
| Podman Desktop | Lima plugin برای VM backend |
| lima-gui | Qt GUI |
| xbar plugin | menu bar start/stop |
انتخاب Colima vs raw Lima = UX و defaults — hypervisor همان Lima class است.
limactl Commands
limactl list # instances
limactl start default # start VM
limactl stop default
limactl delete default
limactl shell default bash # interactive shell
limactl show-ssh default # SSH config
lima apt update # run in default instance
LIMA_INSTANCE=k8s lima kubectl get podsLogs: ~/.lima/<name>/ha.stderr.log، serial.log
Lima vs WSL2 vs Docker Desktop
| WSL2 | Docker Desktop | Lima | |
|---|---|---|---|
| Host | Windows | macOS/Win/Linux | macOS/Linux |
| Integration | deep Windows | GUI app | CLI + YAML |
| VM tech | Hyper-V | hidden | QEMU/VZ |
| k8s local | kind/manual | built-in | template:k8s |
| Config as code | .wslconfig | limited | lima.yaml |
| License | free | commercial | Apache 2.0 |
Lima vs KubeVirt / Kata
| Lima | KubeVirt | |
|---|---|---|
| Scope | local dev desktop | cluster VM orchestration |
| Orchestrator | limactl | Kubernetes |
| Use case | Mac developer | datacenter VM on K8s |
Lima برای laptop؛ KubeVirt برای production cluster.
Kata داخل Lima VM میتواند nested run شود — advanced testing.
CNCF و Community
| تاریخ | milestone |
|---|---|
| می ۲۰۲۱ | Lima created |
| سپتembre ۲۰۲۲ | CNCF Sandbox |
| اکتبر ۲۰۲۵ | CNCF Incubating |
- Slack:
#limaon CNCF Slack - GitHub Discussions
- Monthly community meetings
Troubleshooting
| مشکل | fix |
|---|---|
| VM slow boot | --vm-type=vz روی macOS |
| Mount permission denied | writable mount، check virtiofs |
| SSH fail | ~/.lima/*/ha.stderr.log |
| Port not reachable | check portForwards، firewall |
| x86 image on ARM slow | expected — use ARM images when possible |
| Disk full | limactl delete old instances |
| nerdctl not found | wrong template — use default |
limactl start --debug
limactl validate lima.yamlBest Practices
- VZ on Apple Silicon — performance default
- Separate instances —
dev،k8s،dockerper project - Template in Git — team-shared
lima.yaml - Writable project mount only — not entire
$HOME - nerdctl over hidden Docker — aligned با containerd ecosystem
- Resource limits — CPU/memory در yaml برای laptop battery
limactl stopwhen idle — free RAM
Lima در workflow P30Light
macOS developer laptop
│
▼
Lima VM (Ubuntu + containerd)
├── nerdctl build/run
├── template:k8s → test [Cilium](/blog/cilium-ebpf-kubernetes-networking/) policies
├── [CNB](/blog/cloud-native-buildpacks-cnb-guide/) pack build
└── push registry → production [CRI-O](/blog/cri-o-kubernetes-container-runtime-guide/) clusterLocal dev با Lima — production روی Linux/K8s cluster.
چه زمانی Lima؟
✅ مناسب
- macOS developer — Linux containers بدون Docker Desktop license
- containerd/nerdctl local workflow
- Local Kubernetes — template:k8s
- Cross-arch build — ARM Mac + x86 image
- Declarative VM — lima.yaml in Git
- Colima/Rancher alternative — understand the layer below
❌ کمتر مناسب
| وضعیت | جایگزین |
|---|---|
| Windows primary dev | WSL2 |
| Production VM orchestration | KubeVirt |
| GUI-first non-technical user | Docker Desktop GUI |
| Linux server (native containers) | containerd / Podman direct |
| No VM overhead acceptable | remote Linux dev box |
جمعبندی
| Docker Desktop black box | Lima |
|---|---|
| opaque VM | YAML-configurable |
| vendor lock | open source CNCF |
| one runtime | containerd، Docker، k8s templates |
| GUI required | CLI-first |
Lima Linux VM با ergonomics WSL2-like برای Mac است — با containerd/nerdctl built-in و ecosystem غنی (Colima، Rancher Desktop، Finch).
برای هر developer macOS که با Kubernetes، containerd، یا Linux tooling کار میکند — Lima standard path open-source است.
قدم بعدی
brew install lima && limactl startlima nerdctl run hello-worldlimactl start template:docker— compare Docker UXlimactl start template:k8s— local cluster- Custom
lima.yaml— project-specific CPU/mount - Try Colima — same backend، simpler CLI
منابع:
- Lima — Official Site
- Documentation
- GitHub — lima-vm/lima
- Templates
- Container Examples
- nerdctl
- Colima
- Rancher Desktop
- CNCF Lima Project
منتشر شده در P30Light — بخش زیرساخت سرور و Cloud Native.