Use docker generate dotnet core project images. You need to write Dockerfile file. There are two ways to write, as follows:
The first: the success of the project will be released directly generated image.
FROM microsoft/dotnet:2.2-aspnetcore-runtime WORKDIR /app EXPOSE 5000 COPY bin/Debug/netcoreapp2.2/publish/ app/ ENV ASPNETCORE_URLS http://*:5000 ENTRYPOINT ["dotnet", "app/WebApplication1.dll"]
The second: release the source code to automatically build, publish
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base WORKDIR /app EXPOSE 5000 FROM microsoft/dotnet:2.2-sdk AS build WORKDIR /src COPY . . RUN dotnet restore "WebApplication1.csproj" --configfile NuGet.Config WORKDIR "/src/" RUN dotnet build "WebApplication1.csproj" -c Release -o /app FROM build AS publish RUN dotnet publish "WebApplication1.csproj" -c Release -o /app FROM base AS final WORKDIR /app COPY --from=publish /app . ENV ASPNETCORE_URLS http://*:5000 ENTRYPOINT ["dotnet", "WebApplication1.dll"]
NuGet.Config file contents
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://nuget.cdn.azure.cn/v3/index.json" protocolVersion="3" /> </packageSources> </configuration>