Skip to content

Commit 138cd04

Browse files
gewarrenCopilot
andauthored
Version updates for .NET 10 GA (#49661)
* update version in 'enabled by default' * zone pivots and analysislevel * .net 10 ga updates * reset ca files * fix zone pivot warnings * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 344430c commit 138cd04

31 files changed

+133
-269
lines changed

docs/core/docker/build-container.md

Lines changed: 21 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Containerize an app with Docker tutorial
33
description: In this tutorial, you learn how to containerize a .NET application with Docker.
4-
ms.date: 01/07/2025
4+
ms.date: 11/06/2025
55
ms.topic: tutorial
66
ms.custom: "mvc"
77
zone_pivot_groups: dotnet-version
@@ -33,12 +33,20 @@ You explore the Docker container build and deploy tasks for a .NET application.
3333

3434
Install the following prerequisites:
3535

36+
:::zone pivot="dotnet-10-0"
37+
38+
- [.NET 10+ SDK](https://dotnet.microsoft.com/download/dotnet/10.0).\
39+
If you have .NET installed, use the `dotnet --info` command to determine which SDK you're using.
40+
41+
:::zone-end
42+
3643
:::zone pivot="dotnet-9-0"
3744

3845
- [.NET 9+ SDK](https://dotnet.microsoft.com/download/dotnet/9.0).\
3946
If you have .NET installed, use the `dotnet --info` command to determine which SDK you're using.
4047

4148
:::zone-end
49+
4250
:::zone pivot="dotnet-8-0"
4351

4452
- [.NET 8+ SDK](https://dotnet.microsoft.com/download/dotnet/8.0).\
@@ -99,16 +107,7 @@ Console.WriteLine("Hello World!");
99107
100108
Replace the file with the following code that counts numbers every second:
101109

102-
:::zone pivot="dotnet-9-0"
103-
104-
:::code source="snippets/9.0/App/Program.cs":::
105-
106-
:::zone-end
107-
:::zone pivot="dotnet-8-0"
108-
109-
:::code source="snippets/8.0/App/Program.cs":::
110-
111-
:::zone-end
110+
:::code source="snippets/App/Program.cs":::
112111

113112
Save the file and test the program again with `dotnet run`. Remember that this app runs indefinitely. Use the cancel command <kbd>Ctrl+C</kbd> to stop it. Consider the following example output:
114113

@@ -143,8 +142,6 @@ The `dotnet publish` command compiles your app to the _publish_ folder. The path
143142

144143
From the _App_ folder, get a directory listing of the publish folder to verify that the _DotNet.Docker.dll_ file was created.
145144

146-
:::zone pivot="dotnet-9-0"
147-
148145
```powershell
149146
dir .\bin\Release\net9.0\publish\
150147
@@ -159,46 +156,15 @@ Mode LastWriteTime Length Name
159156
-a---- 1/6/2025 10:11 AM 340 DotNet.Docker.runtimeconfig.json
160157
```
161158

162-
:::zone-end
163-
:::zone pivot="dotnet-8-0"
164-
165-
```powershell
166-
dir .\bin\Release\net8.0\publish\
167-
168-
Directory: C:\Users\default\docker-working\App\bin\Release\net8.0\publish
169-
170-
Mode LastWriteTime Length Name
171-
---- ------------- ------ ----
172-
-a--- 9/22/2023 9:17 AM 431 DotNet.Docker.deps.json
173-
-a--- 9/22/2023 9:17 AM 6144 DotNet.Docker.dll
174-
-a--- 9/22/2023 9:17 AM 157696 DotNet.Docker.exe
175-
-a--- 9/22/2023 9:17 AM 11688 DotNet.Docker.pdb
176-
-a--- 9/22/2023 9:17 AM 353 DotNet.Docker.runtimeconfig.json
177-
```
178-
179-
:::zone-end
180-
181159
#### [Linux](#tab/linux)
182160

183161
Use the `ls` command to get a directory listing and verify that the _DotNet.Docker.dll_ file was created.
184162

185-
:::zone pivot="dotnet-9-0"
186-
187163
```bash
188164
me@DESKTOP:/docker-working/app$ ls bin/Release/net9.0/publish
189165
DotNet.Docker.deps.json DotNet.Docker.dll DotNet.Docker.exe DotNet.Docker.pdb DotNet.Docker.runtimeconfig.json
190166
```
191167

192-
:::zone-end
193-
:::zone pivot="dotnet-8-0"
194-
195-
```bash
196-
me@DESKTOP:/docker-working/app$ ls bin/Release/net8.0/publish
197-
DotNet.Docker.deps.json DotNet.Docker.dll DotNet.Docker.exe DotNet.Docker.pdb DotNet.Docker.runtimeconfig.json
198-
```
199-
200-
:::zone-end
201-
202168
---
203169

204170
## Create the Dockerfile
@@ -207,31 +173,17 @@ The _Dockerfile_ file is used by the `docker build` command to create a containe
207173

208174
Create a file named _Dockerfile_ in the directory containing the _.csproj_ and open it in a text editor. This tutorial uses the ASP.NET Core runtime image (which contains the .NET runtime image) and corresponds with the .NET console application.
209175

210-
:::zone pivot="dotnet-9-0"
211-
212-
:::code language="docker" source="snippets/9.0/App/Dockerfile":::
176+
:::code language="docker" source="snippets/App/Dockerfile":::
213177

214178
> [!NOTE]
215179
> The ASP.NET Core runtime image is used intentionally here, although the `mcr.microsoft.com/dotnet/runtime:9.0` image could be used instead.
216180
217-
:::zone-end
218-
:::zone pivot="dotnet-8-0"
219-
220-
:::code language="docker" source="snippets/8.0/App/Dockerfile":::
221-
222-
> [!NOTE]
223-
> The ASP.NET Core runtime image is used intentionally here, although the `mcr.microsoft.com/dotnet/runtime:8.0` image could be used instead.
224-
225-
:::zone-end
226-
227181
> [!IMPORTANT]
228182
> Including a secure hash algorithm (SHA) after the image tag in a _Dockerfile_ is a best practice. This ensures that the image is not tampered with and that the image is the same as the one you expect. The SHA is a unique identifier for the image. For more information, see [Docker Docs: Pull an image by digest](https://docs.docker.com/reference/cli/docker/image/pull/#pull-an-image-by-digest-immutable-identifier).
229183
230184
> [!TIP]
231185
> This _Dockerfile_ uses multi-stage builds, which optimize the final size of the image by layering the build and leaving only required artifacts. For more information, see [Docker Docs: multi-stage builds](https://docs.docker.com/build/building/multi-stage/).
232186
233-
:::zone pivot="dotnet-9-0"
234-
235187
The `FROM` keyword requires a fully qualified Docker container image name. The Microsoft Container Registry (MCR, mcr.microsoft.com) is a syndicate of Docker Hub, which hosts publicly accessible containers. The `dotnet` segment is the container repository, whereas the `sdk` or `aspnet` segment is the container image name. The image is tagged with `9.0`, which is used for versioning. Thus, `mcr.microsoft.com/dotnet/aspnet:9.0` is the .NET 9.0 runtime. Make sure that you pull the runtime version that matches the runtime targeted by your SDK. For example, the app created in the previous section used the .NET 9.0 SDK, and the base image referred to in the _Dockerfile_ is tagged with **9.0**.
236188

237189
> [!IMPORTANT]
@@ -263,37 +215,6 @@ Save the _Dockerfile_ file. The directory structure of the working folder should
263215
└──...
264216
```
265217

266-
:::zone-end
267-
:::zone pivot="dotnet-8-0"
268-
269-
The `FROM` keyword requires a fully qualified Docker container image name. The Microsoft Container Registry (MCR, mcr.microsoft.com) is a syndicate of Docker Hub, which hosts publicly accessible containers. The `dotnet` segment is the container repository, whereas the `sdk` or `aspnet` segment is the container image name. The image is tagged with `8.0`, which is used for versioning. Thus, `mcr.microsoft.com/dotnet/aspnet:8.0` is the .NET 8.0 runtime. Make sure that you pull the runtime version that matches the runtime targeted by your SDK. For example, the app created in the previous section used the .NET 8.0 SDK, and the base image referred to in the _Dockerfile_ is tagged with **8.0**.
270-
271-
> [!IMPORTANT]
272-
> When using Windows-based container images, you need to specify the image tag beyond simply `8.0`, for example, `mcr.microsoft.com/dotnet/aspnet:8.0-nanoserver-1809` instead of `mcr.microsoft.com/dotnet/aspnet:8.0`. Select an image name based on whether you're using Nano Server or Windows Server Core and which version of that OS. You can find a full list of all supported tags on .NET's [Docker Hub page](https://hub.docker.com/_/microsoft-dotnet).
273-
274-
Save the _Dockerfile_ file. The directory structure of the working folder should look like the following. Some of the deeper-level files and folders are omitted to save space in the article:
275-
276-
```Directory
277-
📁 docker-working
278-
└──📂 App
279-
├── Dockerfile
280-
├── DotNet.Docker.csproj
281-
├── Program.cs
282-
├──📂 bin
283-
│ └──📂 Release
284-
│ └──📂 net8.0
285-
│ └──📂 publish
286-
│ ├── DotNet.Docker.deps.json
287-
│ ├── DotNet.Docker.exe
288-
│ ├── DotNet.Docker.dll
289-
│ ├── DotNet.Docker.pdb
290-
│ └── DotNet.Docker.runtimeconfig.json
291-
└──📁 obj
292-
└──...
293-
```
294-
295-
:::zone-end
296-
297218
The `ENTRYPOINT` instruction sets `dotnet` as the host for the `DotNet.Docker.dll`. However, it's possible to instead define the `ENTRYPOINT` as the app executable itself, relying on the OS as the app host:
298219

299220
```dockerfile
@@ -310,47 +231,20 @@ docker build -t counter-image -f Dockerfile .
310231

311232
Docker processes each line in the _Dockerfile_. The `.` in the `docker build` command sets the build context of the image. The `-f` switch is the path to the _Dockerfile_. This command builds the image and creates a local repository named **counter-image** that points to that image. After this command finishes, run `docker images` to see a list of images installed:
312233

313-
:::zone pivot="dotnet-9-0"
314-
315234
```console
316235
REPOSITORY TAG IMAGE ID CREATED SIZE
317236
counter-image latest 1c1f1433e51d 32 seconds ago 223MB
318237
```
319238

320-
:::zone-end
321-
:::zone pivot="dotnet-8-0"
322-
323-
```console
324-
docker images
325-
REPOSITORY TAG IMAGE ID CREATED SIZE
326-
counter-image latest 2f15637dc1f6 10 minutes ago 217MB
327-
```
328-
329-
:::zone-end
330-
331239
The `counter-image` repository is the name of the image. Additionally, the image tag, image identifier, size and when it was created are all part of the output. The final steps of the _Dockerfile_ are to create a container from the image and run the app, copy the published app to the container, and define the entry point:
332240

333-
:::zone pivot="dotnet-9-0"
334-
335241
```dockerfile
336242
FROM mcr.microsoft.com/dotnet/aspnet:9.0
337243
WORKDIR /App
338244
COPY --from=build /App/out .
339245
ENTRYPOINT ["dotnet", "DotNet.Docker.dll"]
340246
```
341247

342-
:::zone-end
343-
:::zone pivot="dotnet-8-0"
344-
345-
```dockerfile
346-
FROM mcr.microsoft.com/dotnet/aspnet:8.0
347-
WORKDIR /App
348-
COPY --from=build /App/out .
349-
ENTRYPOINT ["dotnet", "DotNet.Docker.dll"]
350-
```
351-
352-
:::zone-end
353-
354248
The `FROM` command specifies the base image and tag to use. The `WORKDIR` command changes the **current directory** inside of the container to _App_.
355249

356250
The `COPY` command tells Docker to copy the specified source directory to a destination folder. In this example, the _publish_ contents in the `build` layer are output into the folder named _App/out_, so it's the source to copy from. All of the published contents in the _App/out_ directory are copied into current working directory (_App_).
@@ -580,6 +474,15 @@ During this tutorial, you created containers and images. If you want, delete the
580474

581475
Next, delete any images that you no longer want on your machine. Delete the image created by your _Dockerfile_ and then delete the .NET image the _Dockerfile_ was based on. You can use the **IMAGE ID** or the **REPOSITORY:TAG** formatted string.
582476

477+
:::zone pivot="dotnet-10-0"
478+
479+
```console
480+
docker rmi counter-image:latest
481+
docker rmi mcr.microsoft.com/dotnet/aspnet:10.0
482+
```
483+
484+
:::zone-end
485+
583486
:::zone pivot="dotnet-9-0"
584487

585488
```console
@@ -588,6 +491,7 @@ docker rmi mcr.microsoft.com/dotnet/aspnet:9.0
588491
```
589492

590493
:::zone-end
494+
591495
:::zone pivot="dotnet-8-0"
592496

593497
```console

docs/core/docker/snippets/8.0/App/Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/core/docker/snippets/8.0/App/DotNet.Docker.csproj

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/core/docker/snippets/9.0/App/Program.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)