Skip to content

Commit dbf3920

Browse files
authored
Use source from snippets in corresponding content (#31757)
1 parent c08930f commit dbf3920

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

docs/core/docker/build-container.md

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,7 @@ Console.WriteLine("Hello World!");
8383
8484
Replace the file with the following code that counts numbers every second:
8585

86-
```csharp
87-
var counter = 0;
88-
var max = args.Length != 0 ? Convert.ToInt32(args[0]) : -1;
89-
while (max == -1 || counter < max)
90-
{
91-
Console.WriteLine($"Counter: {++counter}");
92-
await Task.Delay(TimeSpan.FromMilliseconds(1_000));
93-
}
94-
```
86+
:::code source="snippets/App/Program.cs":::
9587

9688
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. The following is an example output:
9789

@@ -154,23 +146,7 @@ The *Dockerfile* file is used by the `docker build` command to create a containe
154146

155147
Create a file named *Dockerfile* in the directory containing the *.csproj* and open it in a text editor. This tutorial will use the ASP.NET Core runtime image (which contains the .NET runtime image) and corresponds with the .NET console application.
156148

157-
```dockerfile
158-
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
159-
WORKDIR /app
160-
161-
# Copy everything
162-
COPY . ./
163-
# Restore as distinct layers
164-
RUN dotnet restore
165-
# Build and publish a release
166-
RUN dotnet publish -c Release -o out
167-
168-
# Build runtime image
169-
FROM mcr.microsoft.com/dotnet/aspnet:6.0
170-
WORKDIR /app
171-
COPY --from=build-env /app/out .
172-
ENTRYPOINT ["dotnet", "DotNet.Docker.dll"]
173-
```
149+
:::code language="docker" source="snippets/App/Dockerfile":::
174150

175151
> [!NOTE]
176152
> The ASP.NET Core runtime image is used intentionally here, although the `mcr.microsoft.com/dotnet/runtime:6.0` image could have been used.

0 commit comments

Comments
 (0)