Skip to content

Commit 79fb619

Browse files
committed
Add container
1 parent 323789c commit 79fb619

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

docs/core/deploying/index.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ The following table provides quick examples of how to publish your app.
109109
| [Single-file deployment](#single-file-deployment) | `dotnet publish -c Release [-r <RID>] -p:PublishSingleFile=true` |
110110
| [Native AOT deployment](#native-aot-deployment) | `dotnet publish -c Release [-r <RID>] -p:PublishAot=true` |
111111
| [ReadyToRun deployment](#readytorun-deployment) | `dotnet publish -c Release [-r <RID>] -p:PublishReadyToRun=true` |
112+
| [Container deployment](#container-deployment) | `dotnet publish -c Release [-r <RID>] -t:PublishContainer` |
112113

113114
::: zone-end
114115

@@ -431,6 +432,74 @@ dotnet publish -c Release -r <RID> -p:PublishReadyToRun=true
431432

432433
For more information about ReadyToRun deployment, see [ReadyToRun compilation](ready-to-run.md).
433434

435+
## Container deployment
436+
437+
When you publish your app as a container, the .NET SDK packages your application and its dependencies into a container image without requiring a separate Dockerfile. This deployment mode creates a complete container image that can be run on any container runtime, such as Docker or Podman. Container deployment simplifies the containerization process by eliminating the need to write and maintain Dockerfiles while providing optimized base images.
438+
439+
Starting with .NET SDK 8.0.200, container support is included by default and doesn't require additional NuGet packages. For console applications, you might need to enable container support explicitly by setting the `EnableSdkContainerSupport` property to `true`.
440+
441+
> [!TIP]
442+
> For more information about project settings related to containers, see [Containerize a .NET app reference](../containers/publish-configuration.md).
443+
444+
**Advantages**
445+
446+
- **Simplified containerization**: No need to write or maintain Dockerfiles for basic scenarios.
447+
- **Optimized base images**: Uses Microsoft-provided, optimized base images with the latest security updates.
448+
- **Consistent environment**: Ensures consistent runtime environment across development, testing, and production.
449+
- **Easy distribution**: Container images can be easily shared and deployed across different environments.
450+
- **Platform isolation**: Applications run in isolated containers, reducing conflicts between applications.
451+
452+
**Disadvantages**
453+
454+
- **Container runtime dependency**: The target environment must have a container runtime installed.
455+
- **Image size**: Container images are typically larger than other deployment methods.
456+
- **Learning curve**: Requires understanding of container concepts and tooling.
457+
- **Limited customization**: Less flexibility compared to custom Dockerfiles for complex scenarios.
458+
459+
### Publish
460+
461+
::: zone pivot="cli,vscode"
462+
463+
```dotnetcli
464+
dotnet publish -c Release [-r <RID>] /t:PublishContainer
465+
```
466+
467+
- [!INCLUDE [cli-c-release](includes/cli-c-release.md)]
468+
469+
- [!INCLUDE [cli-r-rid](includes/cli-r-rid.md)]
470+
471+
- `-t:PublishContainer`
472+
473+
This target publishes the application as a container image.
474+
475+
You can also use the publish profile approach:
476+
477+
```dotnetcli
478+
dotnet publish -c Release [-r <RID>] -p:PublishProfile=DefaultContainer
479+
```
480+
481+
- `-p:PublishProfile=DefaultContainer`
482+
483+
This profile triggers the container publishing process.
484+
485+
::: zone-end
486+
487+
::: zone pivot="visualstudio"
488+
489+
01. Right-click on the project in **Solution Explorer** and select **Publish**.
490+
01. Select **Container Registry** as the publish target and click **Next**.
491+
01. Choose your target container registry (such as **Azure Container Registry**, **Docker Hub**, or **Generic Registry**) and click **Next**.
492+
01. Configure the registry connection details and authentication.
493+
01. In the publish profile, click **Show all settings**.
494+
01. Set **Deployment Mode** to **Self-contained** or **Framework-dependent** based on your needs.
495+
01. Set **Target Runtime** to your desired platform (for example, **linux-x64** for Linux containers).
496+
01. Configure container-specific settings like image name and tags.
497+
01. Click **Save** and then **Publish**.
498+
499+
::: zone-end
500+
501+
For more information about container deployment, see [.NET SDK container creation overview](../containers/overview.md).
502+
434503
## See also
435504

436505
- [.NET Runtime Identifier (RID) catalog](../rid-catalog.md)

0 commit comments

Comments
 (0)