打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Docker部署.net core mvc项目
 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
项目运行结果如下:
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Hosting and ASP.NET Core API in a Container Part 1...
.NET 5 部署在docker上运行
利用VS code 远程调试 docker 中的 dotnet 应用
超简单让.NET Core开发者快速拥有CI/CD的能力-Docker版本
docker 发布 dotnet3.1 web
.net Core项目发布到Docker for Windows
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服