Skip to content

Commit 323572a

Browse files
Merge pull request #10319 from MicrosoftDocs/main638573547098970833sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents a2d6cbd + d1f576d commit 323572a

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed
Loading
Loading

docs/containers/overview.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,33 @@ ENTRYPOINT ["dotnet", "WebApplication-Docker.dll"]
129129

130130
## Add Docker support using the Dockerfile container build type
131131

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+
![Screenshot showing the Container Scaffolding Options dialog for adding Docker support.](./media/overview/vs-2022/container-scaffolding-options.png)
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.
133159

134160
If you choose **Dockerfile**, Visual Studio adds the following to the project:
135161

@@ -168,7 +194,11 @@ ENTRYPOINT ["dotnet", "WebApplication-Docker.dll"]
168194

169195
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*.
170196

171-
![Screenshot showing the Container Scaffolding Options dialog for adding Docker support.](./media/overview/vs-2022/container-scaffolding-options.png)
197+
![Screenshot showing the Container Scaffolding Options dialog for adding Docker support with .NET SDK selected as the container build type.](./media/overview/vs-2022/container-scaffolding-options-net-sdk.png)
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.
172202

173203
The .NET SDK container build entry in *launchSettings.json* looks like the following code:
174204

@@ -186,7 +216,13 @@ The .NET SDK container build entry in *launchSettings.json* looks like the follo
186216
}
187217
```
188218

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.
220+
221+
```xml
222+
<PropertyGroup>
223+
<ContainerBaseImage>mcr.microsoft.com/dotnet/runtime:8.0-alpine-amd64</ContainerBaseImage>
224+
</PropertyGroup>
225+
```
190226

191227
:::moniker-end
192228

0 commit comments

Comments
 (0)