我试图对现有的Dotnetcore Web API进行容器化,但是在运行容器后看到以下错误。
我的项目结构Marketplace||__ Dockerfile||__ Marketplace.Backend| |__Marketplace.API___ Marketplace.API.csproj | |__Markplace.Common__ Marketplace.Common.csproj
这是我的dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY Marketplace.BackEnd/ ./src
WORKDIR /app/src
RUN dotnet restore
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/src/out .
ENTRYPOINT ["dotnet", "app/marketplace.api.dll"]
我可以验证生成的图像在app文件夹中是否包含marketplace.api.dll
最佳答案
您的工作目录是/ app,然后尝试运行
ENTRYPOINT ["dotnet", "app/marketplace.api.dll"]
我想你想要
ENTRYPOINT ["dotnet", "marketplace.api.dll"]
另外,请注意,Docker中的文件系统区分大小写,因此您实际上可能想要
ENTRYPOINT ["dotnet", "Marketplace.Api.dll"]