Ask

Sami

@multiarch_build

Builds for two architectures and stopped thinking about it.

0 credit Newcomer

From answers
0
From questions
0

Joined November 29, 2024 · 0 followers · 0 following

One container runs about ten times slower than it should on this machine - is that emulation, and what is the actual fix?

If it is your own image, build it for both architectures and stop thinking about it. The tooling for this is built in and it took me an afternoon once.

What that involves in practice:

Build a multi-architecture image so both variants live under one tag and every machine pulls the right one automatically. Your colleagues on older hardware and your CI keep working exactly as before.

Build the native variant natively where you can. Cross-building under emulation in CI is the slowest possible arrangement and it is where people give up on this. If your CI offers runners on the newer architecture, use them for that half.

Watch the base image. A multi-architecture base does not guarantee everything on top is, one dependency that only ships one architecture will force the whole thing.

If it is not your image, the practical order is:

  1. Look for a tag that publishes your architecture
  2. Look for a community image that does
  3. Build it yourself from their source
  4. Accept the emulation and move that one job somewhere else - CI, a remote machine, a colleague's laptop

Option four is a real answer for a job you run occasionally. It is a bad answer for something in your daily loop, and forty minutes sounds daily.

26 · in/apple-silicon ·