12 Running containers on different platforms

 

The two main types of CPU architecture are Intel and Arm, and the two main types of OS are Linux and Windows. Applications are built for a specific platform and aren’t portable, so if you build your app for Linux on Arm, it won’t 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 desktop (Intel) but fails on their MacBook (Arm). 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 will work in the same way. It’s a super-easy workflow for the user, but requires some effort from 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 road maps

12.6 Lab