1 #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 3 FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base 4 WORKDIR /app 5 EXPOSE 80 6 EXPOSE 443 7 8 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build 9 WORKDIR /src 10 COPY ['test.csproj', 'test/'] 11 RUN dotnet restore './test.csproj' 12 COPY . . 13 WORKDIR '/src/.' 14 RUN dotnet build 'test.csproj' -c Release -o /app/build 15 16 FROM build AS publish 17 RUN dotnet publish 'test.csproj' -c Release -o /app/publish 18 19 FROM base AS final 20 WORKDIR /app 21 COPY --from=publish /app/publish . 22 ENTRYPOINT ['dotnet', 'test.dll'] 3.远程部署
通过Xftp远程Linux,把上述项目文件拷贝到系统文件下
4.项目运行
docker run -itd -p 端口名称:80 项目名称
docker build -t 项目名称 -f Dockerfile .
本次实例项目名称:test01,端口号:8082
进入test文件夹:
docker build -t test01 -f Dockerfile .
注:Dockerfile后面有个点“.”
docker run -itd -p 8082:80 test01
项目运行结果如下:
|
|