Running this command –
docker buildx build --platforms linux/amd64,linux/arm64 -t mytag --push .
It creates an image index and 2 images in my ECR.
- How do I tag the images and the image index in one command? For now I can only tag the image index.
- How can I know for sure that each image is different arch and the image index contains both images?
- If I pull the image index from amd64 or arm64 laptop, would he know to pull the right image for my arch? how? I wanted to have multi arch image, is it the image index?
2
Answers
The
buildx
command does not provide this functionality. The intended behavior is that the individual images for each architecture are untagged. You can, however, tag the images yourself using the ECR APIs (i.e.,put-image
) or by pulling the image by digest tagging/pushing new tags (i.e.,docker pull
thendocker tag
, thendocker push
).You can view the image manifest (which can be retrieved with
batch-get-image
), which will specify each image, its digest, and architecture information.You can use this information to verify an image you pull.
You can also use
docker image inspect
to view the architecture of an image you pulled:In the response JSON body, there is a key
"Architecture"
that specifies the architecture.It’s also worth mentioning that the docker client will automatically pull the appropriate architecture according to the daemon host’s architecture. For example, you can use the same command like
docker pull postgres
on an AMD64 machine and ARM machine and the appropriate image will be pulled according to the system architecture.There are a variety of tools out there for this. The ones I frequently recommend are Google’s crane, RedHat’s skopeo, and my own regclient. E.g. with regclient/regctl:
You can inspect the manifest, docker now has this built-in:
Or with various other tools:
Yes, the image index is how a registry stores a multi-platform image. It contains an array of descriptors to each other other manifests and their platform. The container runtimes (like docker) know how to pick their local platform from that list. E.g. here’s what the busybox multi-platform manifest looks like:
From the comments:
The size in the manifest list is the size of each of the nested manifests, which is also just JSON. You need to look at the size of the filesystem layers within those image manifests to see each image size: