Skip to content

[PDLC] Multiarch Images

Description

There are Use-Cases making deployments on machine architectures such us arm64/v8.

I propose to adapt our images to support the following architectures:

  • linux/arm/v7
  • linux/arm64/v8
  • linux/amd64

Proposed Solution

To Update the current Images

  1. Install Docker's buildx if you do not have it already installed
  2. Create a Folder to use as a temp
mkdir temp_folder
cd temp_folder
  1. Create a Dockerfile from the already existing image Change the multiarch-example:original to your own image_name:tag
echo "FROM docker.io/hecodeco/multiarch-example:original" > Dockerfile
  1. Recreate your image (below I am giving a new tag as well) - This will take some time.
docker buildx build \
--push \
--platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
--tag docker.io/hecodeco/multiarch-example:buildx-latest \
.
  1. Verify the Rebuilt Image
docker buildx imagetools inspect docker.io/hecodeco/multiarch-example:buildx-latest
  1. Remove the temp folder
cd ..
rm -rf temp_folder

After the above, you will also be able to see more Digest options in Dockerhub. For example, check the Digest Options of DP on the 2.3.3-multiarch tag.

To keep using Multiarch Images

From now on, we can build (and push our images) using the following command:

docker buildx build \
--push \
--platform linux/amd64,linux/arm/v7,linux/arm64/v8 \
--tag your-username/multiarch-example:buildx-latest .

Some more Assistanse

To update your Docker Builder to have multiarch creation features do the following:

docker buildx create --name mybuilder --use

Refferences

Edited by Panagiotis Karamolegkos