How to build docker images so that they run on both Intel and ARM architectures using the old manifest method. This is also extremly handy if the docker files for the different architectures are different. The modern way of using
docker buildx assumes all architectures use the same Dockerfile.
This turorial shows you how to merge two pre-existing docker images build for two different architectures into one tag so that the client can use respective architecture at run time.
Here’s how you do it
Create and push the images for each architecture
# amd64 architecture docker build -t $CI_REGISTRY_IMAGE:latest-amd64 -f Dockerfile.amd64 . docker push $CI_REGISTRY_IMAGE:latest-amd64 # arm64 image docker build -t $CI_REGISTRY_IMAGE:latest-arm64 -f Dockerfile.arm64 . docker push $CI_REGISTRY_IMAGE:latest-arm64
Note: Building multi platform docker images is out of scope of this post
Create a manifest and push it to the registry
docker manifest create $CI_REGISTRY_IMAGE:latest --amend $CI_REGISTRY_IMAGE:latest-amd64 --amend $CI_REGISTRY_IMAGE:latest-arm64 docker manifest push $CI_REGISTRY_IMAGE:latest
Inspect the combined image
docker manifest inspect $CI_REGISTRY_IMAGE:latest