.net project deployment Docker

1. Create a Dockerfile file in the bin directory generated by the project

#运行环境描述,此处是用的Net5构建镜像
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
#复制文件到 docker容器中的app文件夹中 
COPY . /app
#设置工作目录为 app 文件夹,要和上面一致哦
WORKDIR /app
#设置Docker容器对外暴露80端口
EXPOSE 8888
#使用`LotteryTicket.dll`来运行应用程序
ENTRYPOINT ["dotnet", "LotteryTicket.dll"]

2. Make the image blog2 jar package name. Search Dockerfile

docker build -t cp:v3 .

3. Start the image

docker run -it -d -p 8888:8888 --name=cp 26eaa547c240

Guess you like

Origin blog.csdn.net/wwwwerewrew/article/details/132684501