DEV Community

Cover image for WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)
Ajeet Singh Raina for Docker

Posted on • Originally published at collabnix.com

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)

This warning message indicates that there is a platform mismatch between the requested Docker image and the host platform. The requested image was likely built for the Linux/amd64 platform, but the host platform where the Docker image is being executed is Linux/arm64/v8.

This can cause compatibility issues and may result in errors or unexpected behavior. To resolve this issue, you may need to obtain a version of the image that is compatible with the host platform, or update the host platform to match the platform for which the image was built. But before that, let us understand the problem statement more deeply.

Meet Rosetta 2

Rosetta 2 is a dynamic binary translator designed by Apple for use on Mac computers with Apple Silicon processors. It allows these computers to run software that was originally designed for Macs with Intel processors, which used a different instruction set architecture (ISA) called x86.

Image1

How it works?

Rosetta 2 works by translating x86 instructions into ARM instructions, which are the ISA used by Apple Silicon processors. This translation happens in real-time as the software is running, which means that most applications can be used without any noticeable performance penalty.

Rosetta 2 is included with macOS Big Sur, which was released in November 2020. It runs automatically when you try to open an app that was built for x86 processors, and it usually works seamlessly in the background without any user intervention.

In addition to allowing Macs with Apple Silicon processors to run x86 applications, Rosetta 2 also includes some optimizations that can improve performance for certain types of software. For example, Rosetta 2 can use the neural engine in Apple Silicon processors to accelerate machine learning workloads.

Rosetta 2 is an important tool that allows Mac users to continue using their favorite software while transitioning to a new hardware platform. It demonstrates Apple's commitment to providing a smooth and seamless user experience, even during major platform transitions.

How to run x86 containers on Apple Mac M1 Pro

There are a few workarounds you can use to run x86 containers on your Apple Silicon Mac. One option is to use a virtualization solution like Parallels Desktop or VMware Fusion to run a full-fledged virtual machine that can run x86 containers. Another option but the easiest one is to use a tool like Docker Desktop for Mac, which includes a built-in virtualization solution that allows you to run x86 containers on your Mac. Running x86 containers on Apple Silicon Macs just got easier thanks to newly added Docker’s Rosetta support.

Rosetta is for AMD64 binaries of Docker itself, QEMU is for running the containers. New Beta feature for MacOS 13, Rosetta for Linux, has been added for faster emulation of Intel-based images on Apple Silicon.

Pre-requisite:

  • Docker Desktop 4.16

  • Enable Rosetta 2 Virtualization feature in Docker Desktop

Go to the Settings > section and check the box to enable the Apple Virtualization framework.

Image2

Under the "Feature in development section", enable Rosetta.

Image3

After changing these settings, the Docker Desktop app may restart before becoming available again.

Run x86 containers with Rosetta

If you want to build and run x86 container images using Rosetta, use the platform flag as in the following commands:

docker build --platform linux/amd64 -t nginx:latest .
Enter fullscreen mode Exit fullscreen mode
docker run --platform linux/amd64 nginx:latest
Enter fullscreen mode Exit fullscreen mode

Using Docker Compose

Here's an example of a Docker Compose file that specifies the platform as linux/amd64:

services:
  web:
    platform: linux/amd64
    image: nginx:latest
    ports:
      - "8080:80"
Enter fullscreen mode Exit fullscreen mode

In this example, we have a single service called web that uses the nginx:latest image, which is built for the linux/amd64 platform. We've also specified that the service should be accessible on port 8080 on the host machine, which is mapped to port 80 inside the container.

Latest comments (0)