You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Add Docker support using the Dockerfile container build type
131
131
132
-
When you add or enable Docker support to a .NET 7 or later project, Visual Studio shows the **Container Scaffolding Options** dialog box, which gives you the choice of operating system (Linux or Windows), but also the ability to choose the container build type, either **Dockerfile** or **.NET SDK**.
132
+
When you add or enable Docker support to a .NET 7 or later project, Visual Studio shows the **Container Scaffolding Options** dialog box, which gives you the choice of operating system (Linux or Windows), but also the ability to choose the container build type, either **Dockerfile** or **.NET SDK**. This dialog box does not appear in .NET Framework projects or Azure Functions projects.
133
+
134
+
In 17.11 and later, you can also specify the **Container Image Distro** and the **Docker Build Context**.
135
+
136
+

137
+
138
+
**Container Image Distro** specifies which OS image your containers use as the base image. This list changes if you switch between Linux and Windows as the container type.
139
+
140
+
The following images are available:
141
+
142
+
Windows:
143
+
144
+
- Windows Nano Server (recommended, only available 8.0 and later, not preset for [Native Ahead-of-time (AOT) deployment](/dotnet/core/deploying/native-aot/) projects)
145
+
- Windows Server Core (only available 8.0 and later)
146
+
147
+
Linux:
148
+
149
+
- Default (Debian, but the tag is "8.0")
150
+
- Debian
151
+
- Ubuntu
152
+
- Chiseled Ubuntu
153
+
- Alpine
154
+
155
+
> [!NOTE]
156
+
> Containers based on the Chiseled Ubuntu image and that use [Native Ahead-of-time (AOT) deployment](/dotnet/core/deploying/native-aot/) can only be debugged in Fast Mode. See [Customize Docker containers in Visual Studio](container-build.md).
157
+
158
+
**Docker Build Context** specifies the folder that is used for the Docker build. See [Docker build context](https://docs.docker.com/build/building/context/). The default is the solution folder, which is strongly recommended. All the files needed for a build need to be under this folder, which is usually not the case if you choose the project folder or some other folder.
133
159
134
160
If you choose **Dockerfile**, Visual Studio adds the following to the project:
With Visual Studio 2022 17.9 and later with the .NET 7 SDK installed, in ASP.NET Core projects that target .NET 6 or later, you have the option of using .NET SDK's built-in support for container builds, which means you don't need a Dockerfile; see [Containerize a .NET app with dotnet publish](/dotnet/core/docker/publish-as-container?pivots=dotnet-8-0). Instead, you configure your containers using MSBuild properties in the project file, and the settings for launching the containers with Visual Studio are encoded in a `.json` configuration file, *launchSettings.json*.
170
196
171
-

197
+

198
+
199
+
Here, choose **.NET SDK** as the container build type to use .NET SDK's container management instead of a Dockerfile.
200
+
201
+
**Container Image Distro** specifies which OS image your containers use as the base image. This list changes if you switch between Linux and Windows as the container. See the previous section for a list of available images.
172
202
173
203
The .NET SDK container build entry in *launchSettings.json* looks like the following code:
174
204
@@ -186,7 +216,13 @@ The .NET SDK container build entry in *launchSettings.json* looks like the follo
186
216
}
187
217
```
188
218
189
-
The .NET SDK manages some of the choices that would have been encoded in a Dockerfile, such as the container base image that is chosen to match the targeted version of .NET, and the environment variables to set. The settings available in the project file for container configuration are listed at [Customizing your container](https://github.com/dotnet/sdk-container-builds/blob/main/docs/ContainerCustomization.md).
219
+
The .NET SDK manages some of the settings that would have been encoded in a Dockerfile, such as the container base image, and the environment variables to set. The settings available in the project file for container configuration are listed at [Customizing your container](https://github.com/dotnet/sdk-container-builds/blob/main/docs/ContainerCustomization.md). For example, the **Container Image Distro** is saved in the project file as the `ContainerBaseImage` property. You can change it later by editing the project file.
0 commit comments