Error: Failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest when building docker image

Viewed 38766

I get the error:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest

when building the following Dockerfile:

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
COPY . /inetpub/wwwroot
8 Answers

The cause was simple, i had my docker desktop running on linux containers and the image is build from a windows image.

Simply switching to windows containers solved the problem.

The message is clueless, so i hope this save some time to others.

In my case i was using mac with m1 processor to run a python image, my docker-compose and Dockerfile looked like this:

docker-compose.yml

version: '3.7'

services:
  words_bot:
    build: .
    restart: unless-stopped

Dockerfile:

FROM python:3-onbuild
COPY . /usr/src/app
CMD ["python", "-m", "bot"]

Seems like the image was expecting an x86 host architecture so i was getting the error the OP is referring to.

After I added platform: linux/amd64 into docker-compose.yml everything started working as expected:

version: '3.7'

services:
  cng_words_bot:
    build: .
    platform: linux/amd64
    restart: unless-stopped

Providing platform in docker file on M1 fixed for me

e.g. FROM --platform=linux/amd64 amazonlinux:2018.03

Docker gets confused with some architecture (M1 for instance). Make sure to specify the architecture (platform)

  services:
      service-name:
        platform: linux/x86_64. # specify the architecture here
        image: some-image

For me, docker image itself was not building. So I had to add --platform linux/x86_64 as parameter for docker build command.

On macOS with an Intel chip building a "standard" docker image I ran in to this.

Restarting the Docker daemon fixed it for me.

(Assuming you are running Docker in Windows platform) To resolve this issue, switch the container from Linux to Windows by right clicking on the Docker icon in the tray (we see this icon near the system clock after starting the Docker Engine) and select the option "Switch to Windows containers..."

Step 1
Step 1

Step 2
Step 2

Just stumbled over similar issue myself when using docker build on a very simple Dockerfile:

FROM node:lts-alpine

COPY ./ /app/
RUN cd /app && npm ci && npm run build

When running docker build -t foo ., the OPs error with a slightly different cause came up.

However, when running docker pull node:lts-alpine first, then repeat that build command, the build was running just fine.

IMHO, this looks like a hickup in Docker for Windows. Switching to Windows containers didn't seem like a reasonable option here for the base container is pretty valid for a Linux-based context. Tried to switch anyways, but that was bringing up a different error of Docker for Windows, only.

Related