Reputation: 508
I made a simple .Net 6.0 console app and i built it using dotnet publish command with the flag of linux-arm
dotnet pubish -c release -r linux-arm
Above generates the linux ARM dll's.
Then I created an image for it using Dockerfile
FROM mcr.microsoft.com/dotnet/runtime:6.0
COPY bin/Release/net6.0/linux-arm /MyDockerApp
WORKDIR /MyDockerApp
ENTRYPOINT ["dotnet", "DockerTest.dll"]
(I am not building it, since my code is already built for arm-v7 using dotnet publish)
Now I am trying to run this image as a container on my Raspberry pi (which is Arm/Linux/v7) and i am getting below error.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested standard_init_linux.go:228: exec user process caused: exec format error
How can I compile it so I can run it on my Raspberrypi 4 (I dont want to build my code on Raspberry pi, I just want to use the RunTime).
Upvotes: 0
Views: 4200
Reputation: 1163
Use corresponding ARM .NET runtime image for your RaspberryPI
in your Dockerfile
For example, this one should work
FROM mcr.microsoft.com/dotnet/runtime:6.0.0-focal-arm32v7
instead of default
FROM mcr.microsoft.com/dotnet/runtime:6.0
which is for regular PC.
Upvotes: 3