At the end of the build, all of these images are merged together into a single multi-platform image.
When building a multi-platform image from a Dockerfile, effectively your Dockerfile gets built once for each platform. Setting a single target platform is allowed on all buildx drivers. In order to build multi-platform images, we also need to create a builder instance as building multi-platform images is currently only supported when using BuildKit with docker-container and kubernetes drivers. # building an image for two platformsĭocker buildx build -platform=linux/amd64,linux/arm64. To build for multiple platforms together, you can set multiple values with a comma separator. In order to build for a different architecture, you can set the -platform flag, e.g. This way, you get an image that runs on the same machine you are working on. In the next version of Docker CLI, the docker buildcommand will also start to use Buildx by default.īy default, a build executed with Buildx will build an image for the architecture that matches your machine. Buildx can also be used standalone or, for example, to run builds in a Kubernetes cluster. All builds executed via buildx run with Moby Buildkit builder engine. Buildx is a Docker component that enables many powerful build features with a familiar Docker user experience. In order to build multi-platform container images, we will use the docker buildxcommand. In this post, I’ll show some patterns that you can use if you want to get the best performance out of such builds. If you work with containers there is some good tooling available for building multi-platform images when your development teams are using different architectures or you want to deploy to a different architecture from the one that you develop on. With Apple moving all of their machines to their custom ARM-based silicon and AWS offering the best performance-per-cost ratio with their Graviton2 instances, one can no longer expect that all software only needs to run on x86 processors. There are some important changes happening in the software industry.