There is quite a few blogs around how to build multi-arch docker images. We found most of them bit complicated and confusing. Here is our version of “complicated”. With languages like Go it is easy. but not this is the case for non-compiled languages like Python. For them all supporting libraries must be there.
You can build multi-arch images multiple ways. Most popular are:
- Use a separate tags (
image:arm64, image:amd64). Easy to understand and consume. Downside of this approach is that applications deployed on the platforms like Synpse will require different image names, if same application spans different devices. Ontop of this you might find that you need to build images on the devices with specific architectures itself.
docker buildx. This command allows to use built-in multi-arch builders from docker. It will produce single image with multi-arch manifest. It can be seen in the registry itself or by inspecting image. This will present as single image and can be used on multiple devices.
Lets use second method to build images:
- Install emulators:
- Run a build command for single dockerfile:
Our dockerfile is quite simple:
Important note: Some architectures might require different OS level packages, so what works on ARM64 might not work on ARM32. Build time for 32 bit architecture images will take much longer too, .
Important: Sometimes builds goes “bananas up”. So you might need to reset the builder
docker run --rm --privileged multiarch/qemu-user-static --reset -pand reinstall it. More about this
Having same image supporting multi-arch is very convenient when you use platforms like Synpse, where your applications can span multiple architectures on a multiple devices.