Multi-arch Container Image

Zhimin Wen
4 min readDec 6, 2022
Image by Edi Nugraha from Pixabay

You build your application container image on a Linux server, push it over to the Github registry. On your new Apple silicon M1 laptop, you run the image, but received the following warning error message.

podman run -it -d ghcr.io/zhiminwen/niceapp:v1.0
WARNING: image platform ({amd64 linux [] }) does not match the expected platform ({arm64 linux [] })

Check the image,

skopeo inspect docker://ghcr.io/zhiminwen/niceapp:v1.0

{
"Name": "ghcr.io/zhiminwen/niceapp",
...
"Architecture": "amd64",
"Os": "linux",
...

sure enough, the architecture is amd64 only.

Though the container still running, Podman magically emulate the platform as shown below, you may still wonder how to build the multi-arch container images.

[core@localhost ~]$ podman exec -it 96c5d3e46187 sh
/app # ps
PID USER TIME COMMAND
1 root 0:00 {serving} /usr/bin/qemu-x86_64-static /app/./serving
6 root 0:00 {sh} /usr/bin/qemu-x86_64-static /bin/sh
8 root 0:00 /bin/ps

Build Image with Multiple Architecture

For multiple archietecture images, what we can do is to create a list type of manifest that group the different architecture’s image together. Take an example of the golang image, inspect the raw format of it with skopeo.

skopeo inspect docker://docker.io/library/golang --raw |jq

{
"manifests": [
{
"digest": "sha256:d388153691a825844ebb3586dd04d1c60a2215522cc445701424205dffc8a83e",
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"platform": {
"architecture": "amd64",
"os": "linux"
},
"size": 1796
},
{
"digest": "sha256:e5cb8885ac947b0aabf45176975926e050ffcfb1a2265a7021998f727b780351",
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"platform": {
"architecture": "arm",
"os": "linux",
"variant": "v5"
},
"size": 1796
},
{
"digest": "sha256:1c8c4b3c93e7e0303c6b58310e980c6f64ecbe7c68fd74151200f4739bd2c942",
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"platform": {
"architecture": "arm",
"os": "linux",
"variant"…

--

--