12 Running containers on different platforms

 

There are two main types of CPU architecture: Intel and Arm. And there are two main types of operating system: Linux and Windows. Applications are built for a specific platform and are not portable—build your app for Linux on Arm and it will not work on an Intel machine or on Windows. That’s true for container images too, and it can lead to a whole lot of complexity and confusion. Users might find that an image works fine on their (Intel) desktop but fails on their (Arm) MacBook. Luckily, Docker has had this covered for a long time with multi-platform images: These look and behave like normal Docker images, but they’re published with multiple variants, each targeting a different platform, but all using the same image name. When you run a container from a multi-platform image, Docker pulls the matching variant for your CPU and OS. If you use the same image name on a different platform, you’ll get a different image variant, but it will be the same app, and it will work in the same way. It’s a super-easy workflow for the user, but it takes some effort for the image publisher.

In this chapter, you’ll learn various ways to produce multi-platform builds, but if you’re thinking of skipping this one because you don’t use Windows or Arm, you should at least read the first section to learn why this is a game-changing option.

12.1 Why you need to support multiple platforms

12.2 Building multi-platform image variants

12.3 Grouping platform-specific images with manifests

12.4 Building and pushing multi-platform images with Buildx

12.5 Considering platform support in your roadmaps

12.6 Lab