1、需要编写dockerfile文件
# 基础镜像
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
# 工作目录
WORKDIR /app
# 开放访问端口
EXPOSE 8080
# 复制内容到镜像
COPY . /app
# 指定默认入口
ENTRYPOINT ["dotnet", "Web.Admin.dll"]
2、编写docker-compose.yaml文件
version: '3'
services:
frontservice:
container_name: webadmin
build:
context: ./Web.Admin/bin/Debug/net8.0/publish
dockerfile: Dockerfile
ports:
- "8081:8080"
labels:
description: 'webadmin'
restart: always