-
确保已安装好 Docker 并启动 Docker 服务。
-
打开命令行终端,导航到 ASP.NET Core 项目的根目录。
-
使用以下命令在项目文件夹中创建一个 Dockerfile:
touch Dockerfile
或者选择项目>添加>Docker支持
- 使用文本编辑器(如 Notepad++)打开 Dockerfile 文件,并添加以下内容:
#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. #Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. #For more information, please see https://aka.ms/containercompat # 指定基础镜像 FROM mcr.microsoft.com/dotnet/sdk:6.0