Programs.cs内设置80端口
namespace User.API { public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseUrls("http://+:80") .Build(); } }
添加Dockerfile文件
FROM microsoft/aspnetcore-build as build-env WORKDIR /code COPY *.csproj ./ RUN dotnet restore COPY . ./ RUN dotnet publish -c Release -o out FROM microsoft/aspnetcore WORKDIR /app COPY --from=build-env /code/out ./ EXPOSE 80 RUN dotnet USER.API.dll