[Fixed] docker build –platform=linux/amd64 fails: ERROR: failed to solve: no match for platform in manifest – Docker

by
Ali Hasan
boot2docker buildx

Quick Fix: Disable the Use containerd for pulling and storing images flag in Docker Desktop’s development features to resolve the error.

The Problem:

A user is encountering an error "no match for platform in manifest" when attempting to create a Docker image on a Macbook M2 machine using the command "docker build –platform=linux/amd64." Despite configuring Docker Builder for multiplatform builds and confirming that Rosetta qemu emulation is working, the user is unable to save an image locally. Troubleshooting steps such as verifying the platform configuration and checking the underlying kernel architecture have not yielded a solution.

The Solutions:

Solution 1: Disable the ‘Use containerd for pulling and storing images’ feature flag

According to GitHub issue https://github.com/moby/moby/issues/44578, this error is caused by a bug in Docker Desktop 4.20. As a workaround, you can disable the ‘Use containerd for pulling and storing images’ feature flag within the Docker Desktop settings. Here’s how to do it:

  1. Open Docker Desktop.
  2. Click on ‘Settings’ in the menu bar.
  3. Go to ‘Features in development’.
  4. Uncheck the ‘Use containerd for pulling and storing images’ checkbox.

After disabling this feature flag, you should be able to use ‘docker build’ without encountering the ‘no match for platform in manifest’ error.

Solution 2: Ensure Valid Platform Strings

Verify that the platform string used with the `–platform` flag is valid. Ensure that the correct syntax is used, including the `/` and the full platform name (e.g., `linux/amd64` instead of `linux/amd`). Using invalid platform strings will prevent Docker from identifying the correct tag and result in the “no match for platform in manifest” error.

Q&A

How can I use docker build and actually save a docker image locally?

Disable the flag Use containerd for pulling and storing images within the feature of Docker Desktop.

What is the possible cause for this error?

Invalid platform string. Sending an invalid platform string will prevent docker from parsing the correct tag.

Video Explanation:

The following video, titled "Fix Flutter Error: Failure - build failed with an exception - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Here is how I could fix the build error for Flutter app in Android Studio on MacOS.