@@ -86,3 +86,52 @@ rosetta:
8686` ` `
8787{{% /tab %}}
8888{{< /tabpane >}}
89+
90+ ### [Enable Rosetta AOT Caching with CDI spec](#rosetta-aot-caching)
91+ | ⚡ Requirement | Lima >= 2.0, macOS >= 14.0, ARM |
92+ |-------------------|----------------------------------|
93+
94+ Rosetta AOT Caching speeds up containers by saving translated binaries, so they don't need to be translated again.
95+ Learn more: [WWDC2023 video](https://developer.apple.com/videos/play/wwdc2023/10007/?time=721)
96+
97+ **How to use Rosetta AOT Caching:**
98+
99+ - **Run a container:**
100+ Add ` --device=lima-vm.io/rosetta=cached` to your `docker run` command:
101+ ` ` ` bash
102+ docker run --platform=linux/amd64 --device=lima-vm.io/rosetta=cached ...
103+ ` ` `
104+
105+ - **Build an image:**
106+ Add `# syntax=docker/dockerfile:1-labs` at the top of your Dockerfile to enable the `--device` option.
107+ Use `--device=lima-vm.io/rosetta=cached` in your `RUN` command :
108+ ` ` ` Dockerfile
109+ # syntax=docker/dockerfile:1-labs
110+ FROM ...
111+ ...
112+ RUN --device=lima-vm.io/rosetta=cached <your amd64 command>
113+ ` ` `
114+
115+ - **Check if caching works:**
116+ Look for cache files in the VM :
117+ ` ` ` bash
118+ limactl shell {{.Name}} ls -la /var/cache/rosettad
119+ docker run --platform linux/amd64 --device=lima-vm.io/rosetta=cached ubuntu echo hello
120+ limactl shell {{.Name}} ls -la /var/cache/rosettad
121+ # You should see *.aotcache files here
122+ ` ` `
123+
124+ - **Check if Docker recognizes the CDI device:**
125+ Look for CDI info in the output of `docker info` :
126+ ` ` ` console
127+ docker info
128+ ...
129+ CDI spec directories:
130+ /etc/cdi
131+ /var/run/cdi
132+ Discovered Devices:
133+ cdi: lima-vm.io/rosetta=cached
134+ ` ` `
135+
136+ - **Learn more about CDI:**
137+ [CDI spec documentation](https://github.com/cncf-tags/container-device-interface/blob/main/SPEC.md)
0 commit comments