How does docker engine pick the right image from multi-arch?

Hi,

I create my own multi-arch oci images via the yocto project.
This works pretty well for x86/64 and armv7 images.

e.g. I have here[1] an x86/64 and armv7 container which works for me both on various arm32 boards and on an x86/64 with docker.

[1] https://hub.docker.com/repository/docker/reliableembeddedsystems/oci-telegraf-prebuilt/tags?page=1

Please note that for my armv7 images I use those compiler tunes (I know it’s only SW floating point, but that runs on many boars).

TUNE_FEATURES        = "arm armv7a vfp neon"
TARGET_FPU           = "softfp"

On aarch64 things look differently:

for an i.mx8:

TUNE_FEATURES        = "aarch64 cortexa53 crc crypto"
TARGET_FPU           = ""

for a raspberrypi 64:

TUNE_FEATURES        = "aarch64 cortexa72 crc crypto"
TARGET_FPU           = ""

I would like to avoid building the same container for each aarch64 target and also I am not sure whether the docker engine would pick the right one.

  • *)How do you currently manage to build one container image which runs on multiple aarch64 boards?

  • *)How does the docker engine pick out the proper image in case of multi-arch images? Let’s say for performance reasons I would like to build optimized images per architecture some time in the future.

Leverage multi-CPU architecture support | Docker Documentation explains the steps how to build multi arch containers with “docker buildx create” - as a black box. I saw this, but don’t like to use black boxes for many reasons.
There is the open container initiative (oci) which is supported by docker, and I find it more generic.

Can one please explain what happens behind the scenes of “docker buildx create”?

Say you have a hello-world.c and not ready made packages and would like to put this into a container. What compiler tune options are used to compile it?

I can build (in a totally different way) multi arch images like this one[1] mentioned above. I use oci images, which don’t depend on the docker infrastructure to be built and happen to use docker engine to run them (but could use something else as well).

[1] Docker Hub

What are the compiler tune flags used?

As you see you have only one option for linux/arm64 and linux/arm/v7 with this approach.

I built different linux/arm64 images for imx8 and raspberrypi 4.

Also I can potentially build for each armv7 a different image with different compiler tune flags.

What’s the mechanism of the docker engine to pick the right one up?