Dockerize an asnet core webapi

2019-07-08 02:14发布

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

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

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

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

Mine:

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

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 !

1条回答
成全新的幸福
2楼-- · 2019-07-08 03:02

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.

查看更多
登录 后发表回答