Intel-on-ARM and ARM-on-Intel

Lima supports several modes for running Intel-on-ARM and ARM-on-Intel:

  • System emulation: runs a whole VM of a foreign architecture. Slow, but compatible.
  • User-mode emulation: runs containers (or binaries) of a foreign architecture in a native VM. Faster than system emulation, but less compatible.
    • Rosetta: runs Intel containers (or binaries) in an ARM VM on ARM Mac. Faster than QEMU.

System emulation: Intel VM on ARM Host / ARM VM on Intel Host

This mode was previously called “Slow mode” in this documentation.

⚡ RequirementQEMU, lima-additional-guestagents

Lima can run a VM with a foreign architecture, using QEMU.

For port forwarding, the lima-additional-guestagents package has to be installed on the host.

An example configuration:

limactl start --name=x86_64 --vm-type=qemu --arch=x86_64 --plain

See the YAML tab for the explanation of the corresponding CLI flags.

# Starting with Lima v2.0, `vmType` has to be expclitly set to "qemu" on non-Linux hosts.
vmType: "qemu"

# Supported architectures:
#   Non-experimental: aarch64, x86_64
#   Experimental:     armv7l, ppc64le, riscv64, s390x
#
# containerd is not automatically installed for the experimental architectures.
arch: "x86_64"

# A slow host may need `plain` to disable mounts, port forwards, and containerd, so as to avoid timeout.
plain: true

base:
- template:_images/ubuntu

Running a VM with a foreign architecture is extremely slow. Consider using User-mode emulation or Rosetta whenever possible.

Hybrid Hypervisor: faster Intel VM on ARM Mac (experimental)

⚡ RequirementQEMU (patched), macOS >= 15, ARM

Warning Experimental. This uses a QEMU patched outside upstream, and it is not part of a Lima release.

lima-hybrid-hypervisor runs x86_64 VMs on Apple silicon several times faster than QEMU’s TCG emulator (e.g., about 9 times faster for compiling C code), using Hybrid Hypervisor as an accelerator for QEMU. Hybrid Hypervisor translates x86_64 code to AArch64 like TCG, but runs the translated code inside a Hypervisor.framework VM.

Set up:

brew install glib pixman libslirp ninja pkgconf
git clone https://github.com/lima-vm/lima-hybrid-hypervisor.git
cd lima-hybrid-hypervisor
./build.sh
./install.sh

Run:

export QEMU_SYSTEM_X86_64=/opt/lima-hybrid-hypervisor/bin/qemu-system-x86_64.hybrid
limactl start --name=x86_64 --vm-type=qemu --arch=x86_64

The wrapper qemu-system-x86_64.hybrid replaces the default CPU model max with Nehalem, as the engine does not support AVX and several other CPU features.

See the README of lima-hybrid-hypervisor for the benchmark results and the limitations.

User-mode emulation: Intel containers on ARM VM on ARM Host / ARM containers on Intel VM on Intel Host

This mode was previously called “Fast mode” in this documentation.

This mode uses QEMU User Mode Emulation. QEMU User Mode Emulation is significantly faster than QEMU System Mode Emulation, but it often sacrifices compatibility.

Set up:

lima sudo systemctl start containerd
lima sudo nerdctl run --privileged --rm tonistiigi/binfmt:qemu-v10.0.4-56@sha256:30cc9a4d03765acac9be2ed0afc23af1ad018aed2c28ea4be8c2eb9afe03fbd1 --install all

Run containers:

$ lima nerdctl run --platform=amd64 --rm alpine uname -m
x86_64

$ lima nerdctl run --platform=arm64 --rm alpine uname -m
aarch64

Build and push container images:

$ lima nerdctl build --platform=amd64,arm64 -t example.com/foo:latest .
$ lima nerdctl push --all-platforms example.com/foo:latest

See also https://github.com/containerd/nerdctl/blob/main/docs/multi-platform.md

Rosetta: Intel containers on ARM VM on ARM Host

This mode was previously called “Fast mode 2” in this documentation.

⚡ RequirementLima >= 0.14, macOS >= 13.0, ARM

Rosetta is known to be much faster than QEMU User Mode Emulation. Rosetta is available for VZ instances on ARM hosts.

limactl start --vm-type=vz --rosetta
vmType: "vz"
rosetta:
  # Enable Rosetta for Linux.
  # Hint: try `softwareupdate --install-rosetta` if Lima gets stuck at `Installing rosetta...`
  enabled: true
  # Register rosetta to /proc/sys/fs/binfmt_misc
  binfmt: true

Enable Rosetta AOT Caching with CDI spec

⚡ RequirementLima >= 2.0, macOS >= 14.0, ARM

Rosetta AOT Caching speeds up containers by saving translated binaries, so they don’t need to be translated again. Learn more: WWDC2023 video

How to use Rosetta AOT Caching:

  • Run a container: Add --device=lima-vm.io/rosetta=cached to your docker run command:

    docker run --platform=linux/amd64 --device=lima-vm.io/rosetta=cached ...
    
  • Build an image: Add # syntax=docker/dockerfile:1-labs at the top of your Dockerfile to enable the --device option. Use --device=lima-vm.io/rosetta=cached in your RUN command:

    # syntax=docker/dockerfile:1-labs
    FROM ...
    ...
    RUN --device=lima-vm.io/rosetta=cached <your amd64 command>
    
  • Check if caching works: Look for cache files in the VM:

    limactl shell {{.Name}} ls -la /var/cache/rosettad
    docker run --platform linux/amd64 --device=lima-vm.io/rosetta=cached ubuntu echo hello
    limactl shell {{.Name}} ls -la /var/cache/rosettad
    # You should see *.aotcache files here
    
  • Check if Docker recognizes the CDI device: Look for CDI info in the output of docker info:

    docker info
    ...
    CDI spec directories:
      /etc/cdi
      /var/run/cdi
    Discovered Devices:
      cdi: lima-vm.io/rosetta=cached
    
  • Learn more about CDI: CDI spec documentation