













#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 8075 #8075需要和appsettings.json文件中的配置的端口保持一致 #设置时区 ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 复制所有文件到工作目录 COPY . . # 设置运行时的启动命令 test.dll填写你自己项目的dll ENTRYPOINT ["dotnet", "test.dll"]
# 构建Docker镜像
docker build -t test .
# 运行容器,挂载你的代码目录到容器内的/app目录 在这里,/path/to/your/code应该替换为你的本地代码目录的路径。这样,当你修改本地代码时,容器内的应用将自动更新,无需重新构建镜像
docker run -d -p 8075:8075 --name yourappcontainer -v /path/to/your/code:/app yourappname
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。