Published on

Mongo the requested images platform does not match the detected host platform and no specific platform was requested

Authors

Last Modified : Thursday, Aug 22, 2024

Error:

mongo The requested images platform (linux/arm64) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested

Why Did This Happen?

This error typically arises when you build a Docker image on one platform (e.g., Ubuntu on linux/amd64) and try to run it on a different platform (e.g., Red Hat on linux/arm64). Docker images are platform-specific, and without specifying the platform, Docker may attempt to use an incompatible image.

How to Resolve

  1. Build on the Correct Platform:

    • Ensure that you build the Docker image on the same platform where you intend to deploy it. For example, if you plan to use Docker on Red Hat (which might be linux/arm64), build your image on Red Hat or use a compatible platform.
  2. Specify the Platform When Pulling or Building the Image:

    • If you need to use a specific platform image, you can specify the platform explicitly when building or pulling the image. For example:
      docker build --platform linux/amd64 -t myimage .
      docker pull --platform linux/amd64 mongo
      
  3. Use Multi-Arch Images:

    • Some Docker images are multi-architecture (multi-arch), meaning they can run on multiple platforms. Ensure that you’re using a multi-arch image if possible.
  4. Check Docker Desktop Settings:

    • If you’re using Docker Desktop, you can enable experimental features and specify the platform under settings to automatically pull the correct image for your host platform.
  5. Run the Image with Platform Flag:

    • When running the Docker container, specify the platform explicitly to match your host system:
      docker run --platform linux/amd64 myimage
      
  6. Rebuild the Image for Target Platform:

    • If the image is not compatible with your host platform, rebuild it for the target platform using:
      docker buildx build --platform linux/arm64 -t myimage .
      

By following these steps, you can ensure that your Docker images are compatible with the platform on which they will be deployed.


mongo

os

linux

arm64

docker