Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

c# - Docker and ARM64 - Could not load file or assembly

My net core 5 API project builds and runs perfectly on an ARM64 SBC running Armbian. I have tried to get it to run in a Docker container but receive an error 'Could not load file or assembly ‘/MyAPI.dll’. The system cannot find the file specified. I think it must be path related but can't see anything obviously wrong with the Dockerfile

Dockerfile

# Get Base Image (Full .NET Core SDK)
FROM mcr.microsoft.com/dotnet/sdk AS build-env
WORKDIR /app

# Copy csproj and restore
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Generate runtime image
FROM mcr.microsoft.com/dotnet/aspnet
COPY --from=build-env /app/out/ .
ENTRYPOINT ["dotnet", "MyAPI.dll"]
question from:https://stackoverflow.com/questions/65882086/docker-and-arm64-could-not-load-file-or-assembly

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I saw maybe because the of this

RUN dotnet publish -c Release -o out

Should change to the

RUN dotnet publish -c Release -o /app

And the entry point just change to

COPY --from=build-env /app .
ENTRYPOINT ["dotnet", "/app/MyAPI.dll"]

The reason is the output folder /out but you entry point in the root folder so that's throw the exception.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...