我正在尝试将aspnetcore webapi Docker化。我在这里遵循了教程:
https://docs.docker.com/engine/examples/dotnetcore/

但是当我运行容器时,我收到以下消息:

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

我下载代码并从Dockerfile的github站点构建镜像:
https://github.com/dotnet/dotnet-docker-samples/tree/master/aspnetapp

我运行容器...并且它可以工作...我比较了两个Dockerfile,它们非常相似:

矿:
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

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

# Build runtime image
FROM microsoft/aspnetcore:2.0.5
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "fnizz.webapi.dll"]

还有一个来自github示例的代码:
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

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

# build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

如果缺少信息,请告诉我,我将其添加。谢谢 !

最佳答案

尝试删除RUN ln -s fnizz.webapi.dll entrypoint.dll并将ENTRYPOINT更改为ENTRYPOINT [ "dotnet", "entrypoint.dll" ]。我相信dotnet在DLL扩展名上可能会很挑剔。这种模式还使您可以泛化程序集名称-有时很有用。

关于docker - Dockerize asnet核心webapi,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48812386/

10-16 22:26