Multi-arch Docker Images

 

by Adrian Mouat

Although the promise of Docker is the elimination of differences when moving software between environments, you’ll still face the problem that you can’t cross platform boundaries, i.e. you can’t run a Docker image built for x86_64 on a arm board such as the Raspberry Pi. This means that if you want to support multiple architectures, you typically end up tagging images with their arch (e.g. myimage-arm and myimage-x86_64). However, it turns out that the Docker image format already supports multi-platform images (or more accurately, “manifests”), it’s just that tooling is lagging a little behind. This means that you can create and push an image to the Docker Hub that can be downloaded and run successfully on different architectures.

To prove this point, on my x86_64 laptop:

And on a Raspberry Pi:

Note the matching names and digests, but the different architectures. The amouat/debian-multi image is public, so please try this out for yourself.

So how was this sorcery possible? Behind the scenes, the debian-multi manifest actually points to two separate images and the Docker daemon will automatically select the correct one for the current platform. To create the debian-multi manifest, I used the manifest tool by Phil Estes. I started by creating the following YAML file:

Note that it contains links to two separate images – the official debian image for “amd64” and the semi-official “armhf/debian” image for arm (the armhf repos are a great resource for arm images). I then ran the manifest tool to turn the YAML into a proper Docker manifest and push it to the Hub:

And that’s it! Pretty sweet, but it would be even nicer if we didn’t need to use a 3rd party tool and the official images already had multi-arch support – things that are coming soon.

The following two tabs change content below.

Adrian Mouat

Adrian Mouat is Chief Scientist at Container Solutions and the author of the O'Reilly book "Using Docker". He has been a professional software developer for over 10 years, working on a wide range of projects from small webapps to large data mining platforms.

Latest posts by Adrian Mouat (see all)

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *