Dockerize asnet核心webapi [英] Dockerize an asnet core webapi

查看:65
本文介绍了Dockerize asnet核心webapi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to dockerize a aspnetcore webapi. I followed the tutorial here: https://docs.docker.com/engine/examples/dotnetcore/

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

But when I run my container I have this message:

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

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

I download the code and build the image from the Dockerfile the github site:

https://github.com/dotnet/dotnet-docker-samples/tree/master/aspnetapp

我运行容器...而且它的工作原理...我比较了两个Dockerfile,它们非常相似:

I run the container... and it works... I compared two Dockerfile and they are very similar:

矿井:

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示例中获取:

And the one from the github sample:

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

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

If there is missing info, tell me, I'll add it. Thank you !

推荐答案

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

Try dropping a RUN ln -s fnizz.webapi.dll entrypoint.dll and changing your ENTRYPOINT to ENTRYPOINT [ "dotnet", "entrypoint.dll" ]. I believe dotnet might be finnicky on DLL extensions. This pattern also lets you genericize the assembly name -- sometimes useful.

这篇关于Dockerize asnet核心webapi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆