简体   繁体   中英

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

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

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

eg 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

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
步骤1

Step 2
第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.

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

In my case. I was using a Mac M1 , and it was missing a / , like the following:

How it was:

version: '3.6'
services:
  service-name:
    build:
      # It was without the /, like:
      context: .

Fixed:

version: '3.6'
services:
  service-name:
    build:
      # The correct one
      context: ./

The error was:

failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests latest]: 401 Unauthorized

And also I needed to change the credsStore value. More information: docker pull gives error: no basic auth credentials #207

I hope that it helps someone, I spent a lot of time to get it.

Searching for a Docker image tag that works for your hardware architecture fixes it. For instance, if you are using Apple silicon ( M1 or M2 ), the architecture is arm64.

见图片

In my case I was simply disconnected from the wifi, so double-check that you're online before spending hours trying to debug the issue!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM