Dotnet-docker: Can't build arm7 image using buildx.

Created on 31 Aug 2019  路  2Comments  路  Source: dotnet/dotnet-docker

Step to reproduce.

dotnet new console

add Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-disco-arm32v7 AS build
WORKDIR /src
COPY . .
RUN dotnet publish "test1.csproj" -r linux-arm -c Release -o /app --self-contained true /p:PublishTrimmed=true

FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.0-disco-arm32v7AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["./test1"]

When i try build image with:

docker buildx build --platform linux/arm/v7 -t m4rcel/hw:arm .

i got error:

[build 4/4] RUN dotnet publish "test1.csproj" -r linux-arm -c Release -o /app --self-contained true /p:PublishTrimmed=true: dotnet/docker-tools#11 0.426 A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders

I have Rasbberry PI 4 and when i build image on repbian it work's perfectly.

Most helpful comment

I do not believe this issue is related to buildx. You can reproduce the results with docker build -t m4rcel/hw:arm . .NET Core does not support running within QEMU. Docker utilizes QEMU whenever you run an arm image on an amd64 host. You can however build a .NET Core app arm image on an amd64 host by utilizing an amd64 SDK image and target arm during publish. Please note that you will not be able to run the resulting image because of the afore mentioned QEMU limitation with .NET Core.

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-disco AS build
WORKDIR /src
COPY . .
RUN dotnet publish "test1.csproj" -r linux-arm -c Release -o /app --self-contained true /p:PublishTrimmed=true

FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.0-disco-arm32v7 AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["./test1"]

Alternatively you could make use of docker buildx context to be able to utilize your Raspberry PI device to perform the build/run from your amd64 machine.

All 2 comments

I do not believe this issue is related to buildx. You can reproduce the results with docker build -t m4rcel/hw:arm . .NET Core does not support running within QEMU. Docker utilizes QEMU whenever you run an arm image on an amd64 host. You can however build a .NET Core app arm image on an amd64 host by utilizing an amd64 SDK image and target arm during publish. Please note that you will not be able to run the resulting image because of the afore mentioned QEMU limitation with .NET Core.

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-disco AS build
WORKDIR /src
COPY . .
RUN dotnet publish "test1.csproj" -r linux-arm -c Release -o /app --self-contained true /p:PublishTrimmed=true

FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.0-disco-arm32v7 AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["./test1"]

Alternatively you could make use of docker buildx context to be able to utilize your Raspberry PI device to perform the build/run from your amd64 machine.

You are right. Thenks 馃憤

Was this page helpful?
0 / 5 - 0 ratings