Skip to content

Commit 58d9791

Browse files
committed
add docs/multi-arch.md
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 4d7308d commit 58d9791

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Lima is expected to be used on macOS hosts, but can be used on Linux hosts as we
1717

1818
✅ Intel on Intel
1919

20-
✅ ARM on Intel
20+
[ARM on Intel](./docs/multi-arch.md)
2121

2222
✅ ARM on ARM
2323

24-
✅ Intel on ARM
24+
[Intel on ARM](./docs/multi-arch.md)
2525

2626
✅ Various guest Linux distributions: [Alpine](./examples/alpine.yaml), [Arch Linux](./examples/archlinux.yaml), [CentOS](./examples/centos.yaml), [Debian](./examples/debian.yaml), [Fedora](./examples/fedora.yaml), [openSUSE](./examples/opensuse.yaml), [Ubuntu](./examples/ubuntu.yaml) (default), ...
2727

@@ -58,6 +58,8 @@ $ LIMA_INSTANCE=arm lima uname -a
5858
Linux lima-arm 5.11.0-16-generic #17-Ubuntu SMP Wed Apr 14 20:10:16 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
5959
```
6060

61+
See [`./docs/multi-arch.md`](./docs/multi-arch.md) for Intel-on-ARM and ARM-on-Intel .
62+
6163
### Sharing files across macOS and Linux
6264
```console
6365
$ echo "files under /Users on macOS filesystem are readable from Linux" > some-file
@@ -318,7 +320,7 @@ Note: **Only** on macOS versions **before** 10.15.7 you might need to add this e
318320

319321
#### "QEMU is slow"
320322
- Make sure that HVF is enabled with `com.apple.security.hypervisor` entitlement. See ["QEMU crashes with `HV_ERROR`"](#qemu-crashes-with-hv_error).
321-
- Emulating non-native machines (ARM-on-Intel, Intel-on-ARM) is slow by design.
323+
- Emulating non-native machines (ARM-on-Intel, Intel-on-ARM) is slow by design. See [`docs/multi-arch.md`](./docs/multi-arch.md) for a workaround.
322324

323325
#### error "killed -9"
324326
- make sure qemu is codesigned, See ["QEMU crashes with `HV_ERROR`"](#qemu-crashes-with-hv_error).

docs/multi-arch.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Intel-on-ARM and ARM-on-Intel
2+
3+
Lima supports two modes for running Intel-on-ARM and ARM-on-Intel:
4+
- [Slow mode](#slow-mode)
5+
- [Fast mode](#fast-mode)
6+
7+
## [Slow mode: Intel VM on ARM Host / ARM VM on Intel Host](#slow-mode)
8+
9+
Lima can run a VM with a foreign architecture, just by specifying `arch` in the YAML.
10+
11+
```yaml
12+
arch: "x86_64"
13+
# arch: "aarch64"
14+
15+
images:
16+
- location: "https://cloud-images.ubuntu.com/impish/current/impish-server-cloudimg-amd64.img"
17+
arch: "x86_64"
18+
- location: "https://cloud-images.ubuntu.com/impish/current/impish-server-cloudimg-arm64.img"
19+
arch: "aarch64"
20+
21+
# Disable mounts and containerd, otherwise booting up may timeout if the host is slow
22+
mounts: []
23+
containerd:
24+
system: false
25+
user: false
26+
```
27+
28+
Running a VM with a foreign architecture is extremely slow.
29+
Consider using [Fast mode](#fast-mode) whenever possible.
30+
31+
## [Fast mode: Intel containers on ARM VM on ARM Host / ARM containers on Intel VM on Intel Host](#fast-mode)
32+
33+
This mode is significantly faster but often sacrifies compatibility.
34+
35+
Fast mode requires Lima v0.7.3 (nerdctl v0.13.0) or later.
36+
37+
If your VM was created with Lima prior to v0.7.3, you have to recreate the VM with Lima >= 0.7.3,
38+
or upgrade `/usr/local/bin/nerdctl` binary in the VM to [>= 0.13.0](https://github.com/containerd/nerdctl/releases) manually.
39+
40+
Set up:
41+
```bash
42+
lima sudo systemctl start containerd
43+
lima sudo nerdctl run --privileged --rm tonistiigi/binfmt --install all
44+
```
45+
46+
Run containers:
47+
```console
48+
$ lima nerdctl run --platform=amd64 --rm alpine uname -m
49+
x86_64
50+
51+
$ lima nerdctl run --platform=arm64 --rm alpine uname -m
52+
aarch64
53+
```
54+
55+
Build and push container images:
56+
```console
57+
$ lima nerdctl build --platform=amd64,arm64 -t example.com/foo:latest .
58+
$ lima nerdctl push --all-platforms example.com/foo:latest
59+
```
60+
61+
See also https://github.com/containerd/nerdctl/blob/master/docs/multi-platform.md

0 commit comments

Comments
 (0)