【问题标题】:Dockerize an asnet core webapiDockerize 一个 asp net core web api
【发布时间】:2018-07-26 12:19:36
【问题描述】:

我正在尝试 dockerize 一个 aspnetcore webapi。我按照这里的教程: 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

我从 github 站点的 Dockerfile 下载代码并构建镜像:

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"]

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

【问题讨论】:

  • 我相信如果它在那里没有看到你的 dll,你会得到那个错误;我对 dll 名称还有其他奇怪之处,例如它可能会将 .webapi.dll 视为扩展名
  • 谢谢你我试试...我们永远不知道 ;)
  • 我的答案将是一个比项目重命名更容易的实验
  • 好的,我会试试你的答案...只是为了测试,就是这样!!!

标签: docker asp.net-web-api asp.net-core


【解决方案1】:

尝试删除 RUN ln -s fnizz.webapi.dll entrypoint.dll 并将您的 ENTRYPOINT 更改为 ENTRYPOINT [ "dotnet", "entrypoint.dll" ]。我相信dotnet 可能对 DLL 扩展很感兴趣。这种模式还可以让您通用化程序集名称——有时很有用。

【讨论】:

    猜你喜欢
    • 2019-06-29
    • 1970-01-01
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多