نسخه آنلاین در حال بارگذاری زمان... تهران: ۲۶°C
۲۸ کاربر آنلاین

PNo.30Light

نشریه تخصصی هوش مصنوعی، سیستم‌های سرور و مهندسی داده

تازه ترین‌ها
زیرساخت و سرور
زمان مطالعه: ۲۰ دقیقه ۰ بازدید

Lima: ماشین‌های لینوکس روی macOS برای Container — راهنمای کامل

نویسنده: تحریریه فنی P30Light
Lima: ماشین‌های لینوکس روی macOS برای Container — راهنمای کامل
✦ خلاصه نکات کلیدی مقاله
  • Lima (LInux MAc) VM سبک با file sharing و port forwarding — WSL2-like برای macOS/Linux.
  • Default: Ubuntu + containerd + nerdctl — templates برای Docker، k8s، Fedora، Alpine.
  • CNCF Incubating (۲۰۲۵) — backend Colima، Rancher Desktop، Finch، Podman Desktop.

روی 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 DesktopLima
Open sourceclient OSS، engine mixedApache 2.0
Transparencyblack box VMlima.yaml declarative
Runtime choiceMoby fixedcontainerd، Docker، k8s template
HypervisorhiddenQEMU یا Apple VZ
Costenterprise licensefree
Kubernetes localkind in VMtemplate:k8s

Lima چیست؟

Lima CLI برای launch Linux VM با:

  • Automatic file sharing — edit روی host، build در guest
  • Automatic port forwardinglocalhost: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نقش
limactlcreate/start/stop/delete VM instances
limashorthand — run command in default VM
hostagentport forward، mount، lifecycle روی host
guest agentcoordination داخل VM
QEMU / vzhypervisor backend
~/.lima/VM disks، config، logs، sockets

Hypervisor backends

BackendPlatformNotes
vzmacOS ≥13 (Apple Silicon/Intel)Virtualization.framework — سریع‌تر
QEMUmacOS، Linux، Windowscross-arch، compatible
WHPXWindows hostHyper-V
KVMLinux hostnative acceleration
# Apple VZ (توصیه macOS)
limactl start --vm-type=vz

# QEMU (compatibility)
limactl start --vm-type=qemu

نصب و شروع

macOS (Homebrew)

brew install lima
limactl start

Default instance: Ubuntu + containerd + nerdctl.

# Linux command در VM
lima uname -a

# container با nerdctl
lima nerdctl run --rm hello-world

Linux host

# از release binary یا package manager
limactl start

روی Linux host از KVM برای acceleration استفاده می‌شود.


Templates

از templates — prebuilt YAML:

Templateمحتوا
defaultUbuntu + containerd + nerdctl ⭐
dockerDocker Engine + compose
k8sKubernetes (k3s/kubeadm variant)
fedoraFedora Linux
alpineAlpine minimal
debianDebian
archlinuxArch
ubuntuUbuntu 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 nodes
limactl start template:fedora
limactl shell fedora bash

lima.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 dev

containerd و 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 automatic

Rootless nerdctl — optional در config.

برای workflow شبیه Docker:

alias docker='lima nerdctl'
# یا docker-compat plugin

File Sharing

Mount typeNotes
virtiofsdefault روی VZ — سریع
9pQEMU-compatible
reverse-sshfsfallback

Home directory معمولاً read-only mount — project folder را writable mount کنید:

mounts:
  - location: "~/Projects/myapp"
    writable: true

Edit روی 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: tcp

Multi-Architecture

Lima cross-arch پشتیبانی می‌کند:

HostGuestUse case
Apple Silicon (ARM)ARMnative — سریع
Apple Siliconx86_64build Intel images
Intel MacARMtest ARM containers
Intel Macx86_64native
limactl create --arch=x86_64 template:default

Adopters — Ecosystem

Lima engine زیر hood بسیاری از toolهای desktop است:

Projectنقش
ColimaDocker + k8s با minimal setup
Rancher DesktopGUI — k8s + container management
FinchAWS — local container dev
Podman DesktopLima plugin برای VM backend
lima-guiQt GUI
xbar pluginmenu 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 pods

Logs: ~/.lima/<name>/ha.stderr.log، serial.log


Lima vs WSL2 vs Docker Desktop

WSL2Docker DesktopLima
HostWindowsmacOS/Win/LinuxmacOS/Linux
Integrationdeep WindowsGUI appCLI + YAML
VM techHyper-VhiddenQEMU/VZ
k8s localkind/manualbuilt-intemplate:k8s
Config as code.wslconfiglimitedlima.yaml
LicensefreecommercialApache 2.0

Lima vs KubeVirt / Kata

LimaKubeVirt
Scopelocal dev desktopcluster VM orchestration
OrchestratorlimactlKubernetes
Use caseMac developerdatacenter 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: #lima on CNCF Slack
  • GitHub Discussions
  • Monthly community meetings

Troubleshooting

مشکلfix
VM slow boot--vm-type=vz روی macOS
Mount permission deniedwritable mount، check virtiofs
SSH fail~/.lima/*/ha.stderr.log
Port not reachablecheck portForwards، firewall
x86 image on ARM slowexpected — use ARM images when possible
Disk fulllimactl delete old instances
nerdctl not foundwrong template — use default
limactl start --debug
limactl validate lima.yaml

Best Practices

  1. VZ on Apple Silicon — performance default
  2. Separate instancesdev، k8s، docker per project
  3. Template in Git — team-shared lima.yaml
  4. Writable project mount only — not entire $HOME
  5. nerdctl over hidden Docker — aligned با containerd ecosystem
  6. Resource limits — CPU/memory در yaml برای laptop battery
  7. limactl stop when 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/) cluster

Local 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 devWSL2
Production VM orchestrationKubeVirt
GUI-first non-technical userDocker Desktop GUI
Linux server (native containers)containerd / Podman direct
No VM overhead acceptableremote Linux dev box

جمع‌بندی

Docker Desktop black boxLima
opaque VMYAML-configurable
vendor lockopen source CNCF
one runtimecontainerd، Docker، k8s templates
GUI requiredCLI-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 است.

قدم بعدی

  1. brew install lima && limactl start
  2. lima nerdctl run hello-world
  3. limactl start template:docker — compare Docker UX
  4. limactl start template:k8s — local cluster
  5. Custom lima.yaml — project-specific CPU/mount
  6. Try Colima — same backend، simpler CLI

منابع:


منتشر شده در P30Light — بخش زیرساخت سرور و Cloud Native.

لینک گزارش با موفقیت کپی گردید!