2022-12-18

no match for platform in manifest

"no match for platform in manifest" Error

Apple's M1 and M2 chips, based on ARM architecture, have proven to be a game-changer in the computing world. However, this new architecture also brings certain compatibility issues, especially when using software initially designed for x86-64 platforms. One such issue manifests when you're trying to build a Docker image on an M1/M2 Mac.

If you execute the following Dockerfile with the command docker build .:

Dockerfile
FROM <your image>:latest

You're likely to encounter the error message that reads:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest sha256:8531053692ea6f2876d103be6756e2fbdba8b2332303d88ac03da26455332566: not found

This error is essentially saying that Docker is unable to find a compatible platform for the given manifest SHA-256 hash. It occurs mainly due to a mismatch between the platform you are working on and the platform the Docker image is built for.

Solution

Docker provides a --platform flag that allows you to specify the target platform for your image. By using this flag, you're instructing Docker to pull or build an image compatible with the designated architecture. For example, if you're facing this issue on an M1/M2 Mac and you need to build for a linux/amd64 platform, you can use the following command:

bash
$ docker build --platform linux/amd64 .

This command forces Docker to search for an image manifest that is compatible with the linux/amd64 platform, effectively resolving the "no match for platform in manifest" issue.

If you're using Docker Compose to manage multi-container applications, you can specify the platform in the docker-compose.yml file. Here's how you can do it:

docker-compose.yml
services:
  hoge:
    platform: linux/amd64

This configuration informs Docker Compose that the service hoge should be run using an image built for the linux/amd64 platform.

Ryusei Kakujo

researchgatelinkedingithub

Focusing on data science for mobility

Bench Press 100kg!