The .NET SDK can publish applications directly as container images using `dotnet publish /t:PublishContainer` — no Dockerfile required. This feature, built into the SDK since .NET 8.0.200, handles base image selection, layer creation, tagging, and pushing. The guide covers MSBuild property configuration in .csproj files, benchmarks of 6 base image variants (Alpine cuts size 47%, Chiseled up to 53%, Native AOT + Chiseled achieves ~15 MB), a decision matrix comparing SDK publish vs Dockerfile, multi-architecture image support via ContainerRuntimeIdentifiers, publishing to registries like GHCR/ECR/Docker Hub, tarball export for air-gapped environments, GitHub Actions CI/CD integration, Directory.Build.props for multi-project solutions, and a production hardening checklist covering non-root users, minimal base images, tag pinning, and image scanning.

18m read timeFrom codewithmukesh.com
Post cover image
Table of contents
Docker Essentials for .NET DevelopersWhat Is .NET Built-In Container Support?Why Ditch the Dockerfile?PrerequisitesYour First Container Without a DockerfileCustomizing the Container ImageOptions Pattern in ASP.NET CoreImage Size Benchmarks: Choosing the Right Base ImageCRUD with EF Core in ASP.NET CoreSDK Publish vs Dockerfile: The Decision MatrixMulti-Architecture Images in .NET 10Publishing to Container RegistriesDeploy .NET Web API to Amazon ECS with GitHub ActionsTarball Export for Air-Gapped EnvironmentsClean Architecture TemplateCI/CD with GitHub ActionsDeploy ASP.NET Core Web API to Amazon ECSMulti-Project Solutions with Directory.Build.propsProduction Hardening ChecklistHealthchecks in ASP.NET Core - Detailed GuideStructured Logging with Serilog in ASP.NET CorePodman SupportTroubleshooting Common ErrorsBest AWS Compute Service for Your .NET SolutionKey TakeawaysSummary
2 Impressions