Building multi-platform container images

What is a multi-platform image?

A multi-platform image is an image that comes with built-in support for multiple computing platforms or architectures. Externally, it resembles a standard image with the usual name and tag; however, beneath the surface, it contains essential information enabling deployment on machines featuring various CPUs.

Tanzu Application Catalog provides a comprehensive catalog of 200+ production-ready multi-platform containers, built by leveraging Bitnami’s expertise in packaging hundreds of open source software applications.

Why are multi-platform images important?

The rise of ARM in both personal and cloud computing has had a strong impact on the software industry. This architecture is designed for optimized power efficiency and usually relates to a better price per performance (see article by Percona, as an example).

Managing multiple iterations of the same application can be challenging and time-intensive. Multi-platform images simplify their management and provide a single and consolidated artifact that can be deployed across architectures.

When using the VMware Tanzu Application Catalog, ensure your custom base image is compatible with both ARM and AMD architectures. In the following section, you will find information on how to build multi-architecture images.

Building a multi-platform image

There are various methods and tools for constructing a multi-platform image, but fundamentally, you will need to have:

  • A container build environment that supports multi-platform (for example, docker-desktop).
  • An existing Dockerfile for an application.

One strategy for creating multi-platform images involves using emulation through QEMU. Alternative strategies, like using native workers, often offer improved performance and compatibility but can be more intricate. Therefore, this tutorial uses the docker-desktop approach as it includes all the necessary prerequisites.

Find below the sample Dockerfile for the application to build:

FROM docker.io/bitnami/minideb:bullseye
RUN install_packages wget

To build a multi-platform image:

  1. List the existing builders (in case you already have a matching one for your architectures) and create a new one for the target platforms.

    $ docker buildx ls
    NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT PLATFORMS
    default * docker                           
    default default         running v0.12.5  linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
    
    # Our sample application will be available both in:
    #    * linux/amd64
    #    * linux/arm64
    $ docker buildx create --name SAMPLE_BUILDER --platform linux/amd64,linux/arm64 --use
    SAMPLE_BUILDER
    

    Tip Replace SAMPLE_BUILDER with your desired name for the builder we have just created.

  2. Build the image using the recently created builder.

    # As usual, we need to be in the same directory where 
    # the Dockerfile is to build the image
    $ ls .
    Dockerfile
    
    $ docker buildx build . -t REGISTRY/IMAGE_NAME:TAG --platform linux/amd64,linux/arm64 –-push
    

    Tip Replace REGISTRY, IMAGE_NAME and TAG with your corresponding values.

    The images should work in both architectures now.

    $ docker run --rm -it REGISTRY/IMAGE_NAME:TAG --platform linux/amd64 REGISTRY/IMAGE_NAME:TAG uname -m
    x86_64
    
    $ docker run --rm -it REGISTRY/IMAGE_NAME:TAG --platform linux/arm64 REGISTRY/IMAGE_NAME:TAG uname -m
    aarch64
    
check-circle-line exclamation-circle-line close-line
Scroll to top icon