docker 发布 dotnet3.1 web
1. 配置Dockerfile(这里配置的是已发布的,默认是执行编译及发布的)
# 这种写法 OK Dockerfile文件放置与发布文件加目录下 (dotnet3.1firstdemo )
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
#WORKDIR /app
#EXPOSE 80
#EXPOSE 443
#
#COPY . .
#ENTRYPOINT ["dotnet", "MyFirstAspDotnetCoreDemo.dll"]
# 这种写法不OK
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
#WORKDIR /app
#EXPOSE 80
#EXPOSE 443
#
#COPY dotnet3.1firstdemo app/
#ENTRYPOINT ["dotnet", "app/MyFirstAspDotnetCoreDemo.dll"]
# 这种写法 OK
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
COPY dotnet3.1firstdemo /app/
ENTRYPOINT ["dotnet", "/app/MyFirstAspDotnetCoreDemo.dll"]
# 这种写法 OK Dockerfile文件放置与发布文件加同目录 (dotnet3.1firstdemo )
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
#WORKDIR /app
#EXPOSE 80
#EXPOSE 443
#
#COPY dotnet3.1firstdemo .
#ENTRYPOINT ["dotnet", "MyFirstAspDotnetCoreDemo.dll"]
2.Linux 上站点文件
dotnet3.1firstdemo 文件夹是已发布的站点
3. 执行docker创建镜像
# docker build -t core31:1.0 -f Dockerfile .
4. 启动容器
# docker run -p 8081:6000 -t -d core31:1.0
5. 打开浏览器,查看网站
localhost:8081
6. 停止站点,删除站点
7. 删除镜像
end