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
Copy file name to clipboardExpand all lines: docs/core/docker/publish-as-container.md
+22-22Lines changed: 22 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,11 @@ Install the following prerequisites:
17
17
If you have .NET installed, use the `dotnet --info` command to determine which SDK you're using.
18
18
-[Docker Community Edition](https://www.docker.com/products/docker-desktop)
19
19
20
-
In addition these prerequisites, it's recommended to be familiar with [Worker Services in .NET](../extensions/workers.md).
20
+
In addition to these prerequisites, it's recommended that you're familiar with [Worker Services in .NET](../extensions/workers.md).
21
21
22
22
## Create .NET app
23
23
24
-
You need a .NET app to containerize, so you'll start by creating a new app from a template. Open your terminal, create a working folder (*sample-directory*) if you haven't already, and change directories so that you're in it. In the working folder, run the following command to create a new project in a subdirectory named *Worker*:
24
+
You need a .NET app to containerize, so start by creating a new app from a template. Open your terminal, create a working folder (*sample-directory*) if you haven't already, and change directories so that you're in it. In the working folder, run the following command to create a new project in a subdirectory named *Worker*:
25
25
26
26
```dotnetcli
27
27
dotnet new worker -o Worker -n DotNet.ContainerImage
@@ -45,7 +45,7 @@ Your folder tree will look like the following:
45
45
└── project.nuget.cache
46
46
```
47
47
48
-
The `dotnet new` command creates a new folder named _Worker_ and generates a worker service that when ran will log a message every second. Change directories and navigate into the *Worker- folder, from your terminal session. Use the `dotnet run` command to start the app. The application will run, and print `Hello World!` below the command:
48
+
The `dotnet new` command creates a new folder named _Worker_ and generates a worker service that, when run, logs a message every second. From your terminal session, change directories and navigate into the *Worker- folder. Use the `dotnet run` command to start the app.
49
49
50
50
```dotnetcli
51
51
dotnet run
@@ -73,7 +73,7 @@ The worker template loops indefinitely. Use the cancel command <kbd>Ctrl+C</kbd>
73
73
74
74
## Add NuGet package
75
75
76
-
The .NET 7 SDK will eventually be capable of publishing .NET apps as containers without the use of the [Microsoft.NET.Build.Containers NuGet package](https://libraries.io/nuget/Microsoft.NET.Build.Containers). Until that time, this package is required. To add the `Microsoft.NET.Build.Containers` NuGet package to the worker template, run the following [dotnet add package](../tools/dotnet-add-package.md) command:
76
+
The [Microsoft.NET.Build.Containers NuGet package](https://libraries.io/nuget/Microsoft.NET.Build.Containers) package is currently required to publish an app as a container. To add the `Microsoft.NET.Build.Containers` NuGet package to the worker template, run the following [dotnet add package](../tools/dotnet-add-package.md) command:
77
77
78
78
```dotnetcli
79
79
dotnet add package Microsoft.NET.Build.Containers
@@ -95,7 +95,7 @@ To publish the .NET app as a container, use the following `dotnet publish` comma
95
95
dotnet publish --os linux --arch x64 /t:PublishContainer -c Release
96
96
```
97
97
98
-
The preceding .NET CLI command, publishes the app as a container:
98
+
The preceding .NET CLI command publishes the app as a container:
99
99
100
100
- Targeting Linux as the OS (`--os linux`).
101
101
- Specifying an x64 architecture (`--arch x64`).
@@ -112,7 +112,7 @@ The preceding .NET CLI command, publishes the app as a container:
112
112
> [!TIP]
113
113
> Depending on the type of app you're containerizing, the command-line switches (options) might vary. For example, the `/t:PublishContainer` argument is only required for non-web .NET apps, such as `console` and `worker` templates. For web templates, replace the `/t:PublishContainer` argument with `-p:PublishProfile=DefaultContainer`. For more information, see [.NET SDK container builds, issue #141](https://github.com/dotnet/sdk-container-builds/issues/141).
114
114
115
-
The command will output similar to the following:
115
+
The command will produce output similar to the following:
116
116
117
117
```dotnetcli
118
118
Determining projects to restore...
@@ -129,30 +129,30 @@ This command compiles your worker app to the *publish- folder and pushes the con
129
129
You can control many aspects of the generated container through MSBuild properties. In general, if you could use a command in a _Dockerfile_ to set some configuration, you can do the same via MSBuild.
130
130
131
131
> [!NOTE]
132
-
> The only exception to this are `RUN` commands, due to the way containers are built, those cannot be emulated. If you need this functionality, you will need to use a _Dockerfile_ to build your container images.
132
+
> The only exceptions to this are `RUN` commands. Due to the way containers are built, those cannot be emulated. If you need this functionality, you'll need to use a _Dockerfile_ to build your container images.
133
133
134
134
> [!IMPORTANT]
135
135
> Currently, only Linux containers are supported.
136
136
137
137
### `ContainerBaseImage`
138
138
139
-
The container base image property controls the image used as the basis for your image. By default, we will infer the following values for you based on the properties of your project:
139
+
The container base image property controls the image used as the basis for your image. By default, the following values are inferred based on the properties of your project:
140
140
141
141
- If your project is self-contained, the `mcr.microsoft.com/dotnet/runtime-deps` image is used as the base image.
142
142
- If your project is an ASP.NET Core project, the `mcr.microsoft.com/dotnet/aspnet` image is used as the base image.
143
143
- Otherwise the `mcr.microsoft.com/dotnet/runtime` image is used as the base image.
144
144
145
-
The tag of the image is inferred to be the numeric component of your chosen `TargetFramework`. For example, a project targeting `.net6.0` will result in the `6.0` tag of the inferred base image, a `.net7.0-linux` project will use the `7.0` tag, and so on.
145
+
The tag of the image is inferred to be the numeric component of your chosen `TargetFramework`. For example, a project targeting `.net6.0` will result in the `6.0` tag of the inferred base image, and a `.net7.0-linux` project will use the `7.0` tag.
146
146
147
-
If you set a value here, you should set the fully-qualified name of the image to use as the base, including any tag you prefer:
147
+
If you set a value here, you should set the fullyqualified name of the image to use as the base, including any tag you prefer:
The container registry property controls the destination registry, the place that the newly-created image will be pushed to. Be default, we push to the local Docker daemon (`docker://`), but for this release you can specify any _unauthenticated_ registry. For example, consider the following XML example:
155
+
The container registry property controls the destination registry, the place that the newlycreated image will be pushed to. Be default, it's pushed to the local Docker daemon (`docker://`), but for this release you can specify any _unauthenticated_ registry. For example, consider the following XML example:
@@ -169,9 +169,9 @@ The container image name controls the name of the image itself, e.g `dotnet/runt
169
169
<ContainerImageName>my-app</ContainerImageName>
170
170
```
171
171
172
-
Image names can only contain lowercase alphanumeric characters, periods, underscores, and dashes, and must start with a letter or number, any other characters will result in an error being thrown.
172
+
Image names can only contain lowercase alphanumeric characters, periods, underscores, and dashes, and must start with a letter or number. Any other characters will result in an error being thrown.
173
173
174
-
### `ContainerImageTag(s)`
174
+
### `ContainerImageTags`
175
175
176
176
The container image tag property controls the tags that are generated for the image. Tags are often used to refer to different versions of an application, but they can also refer to different operating system distributions, or even different configurations. By default, the `Version` of the project is used as the tag value. To override the default, specify either of the following:
177
177
@@ -227,16 +227,16 @@ The `ContainerLabel` node has two attributes:
227
227
<ItemGroup>
228
228
```
229
229
230
-
For more information, see [default container labels](#default-container-labels) for a list of labels that are created by default.
230
+
For a list of labels that are created by default, see [default container labels](#default-container-labels).
231
231
232
232
### `ContainerEnvironmentVariable`
233
233
234
-
The container environment variable node allows you to add environment variables to the container. Environment variables will be accessible to the application running in the container immediately, and are often used to change the runtime behavior of the running application.
234
+
The container environment variable node allows you to add environment variables to the container. Environment variables are accessible to the application running in the container immediately, and are often used to change the run-time behavior of the running application.
235
235
236
236
The `ContainerEnvironmentVariable` node has two attributes:
237
237
238
-
-`Include`: The name of the environment variable.
239
-
-`Value`: The value of the environment variable
238
+
-`Include`: The name of the environment variable.
239
+
-`Value`: The value of the environment variable.
240
240
241
241
```xml
242
242
<ItemGroup>
@@ -248,11 +248,11 @@ For more information, see [.NET environment variables](../tools/dotnet-environme
248
248
249
249
### `ContainerEntrypoint`
250
250
251
-
The container entry point can be used to customize the `ENTRYPOINT` of the container, which is the executable that is called when the container is started. By default, for builds that create an app host it is set as the `ContainerEntrypoint`. For builds that don't create an executable, the `dotnet path/to/application.dll` is used as the `ContainerEntrypoint`.
251
+
The container entry point can be used to customize the `ENTRYPOINT` of the container, which is the executable that is called when the container is started. By default, for builds that create an app host, it's set as the `ContainerEntrypoint`. For builds that don't create an executable, the `dotnet path/to/application.dll` is used as the `ContainerEntrypoint`.
252
252
253
253
The `ContainerEntrypoint` node has a single attribute:
254
254
255
-
-`Include`: The command, option, or argument to use in the entrypoint command.
255
+
-`Include`: The command, option, or argument to use in the `ContainerEntrypoint` command.
256
256
257
257
For example, consider the following sample .NET project item group:
258
258
@@ -327,6 +327,6 @@ docker image rm 25aeb97a2e21
327
327
328
328
-[Announcing built-in container support for the .NET SDK](https://devblogs.microsoft.com/dotnet/announcing-builtin-container-support-for-the-dotnet-sdk)
329
329
-[Tutorial: Containerize a .NET app](build-container.md)
330
-
-[Review the Azure services that support containers.](https://azure.microsoft.com/overview/containers/)
331
-
-[Read about Dockerfile commands.](https://docs.docker.com/engine/reference/builder/)
332
-
-[Explore the Container Tools for Visual Studio](/visualstudio/containers/overview)
330
+
-[Review the Azure services that support containers](https://azure.microsoft.com/overview/containers/)
331
+
-[Read about Dockerfile commands](https://docs.docker.com/engine/reference/builder/)
332
+
-[Explore the container tools in Visual Studio](/visualstudio/containers/overview)
0 commit comments