docker

Docker containerization for .NET 10 applications. Covers multi-stage builds, .NET container images, non-root user configuration, health checks, and .dockerignore. Load this skill when containerizing an application with a Dockerfile, optimizing image size, setting up Docker Compose for local developm

By codewithmukesh · 1,192 installs

npx skills add codewithmukesh/dotnet-claude-kit --skill docker

Source repository · Upstream listing

Docker Core Principles 1. Multi stage builds always — Separate build and runtime stages. Build in the SDK image, run in the ASP.NET runtime image. 2. Non root by default — .NET container images support USER app by default since .NET 8. Never run as root in production. 3. Layer caching matters — Copy .csproj files and restore before copying source code. This caches NuGet dependencies across builds. 4. Health probes at the orchestrator level — Expose a /health/live endpoint and let Kubernetes/Compose probe it. Chiseled and default aspnet images have no shell or curl, so in image HEALTHCHECK commands have nothing to run with. Patterns Multi Stage Dockerfile for Web API Container Health Probes Prefer orchestrator level probes (Kubernetes livenessProbe , Compose healthcheck ) over a Dockerfile HEALTHCHECK — the standard aspnet and chiseled images ship no shell, no curl, and no wget, so there is nothing inside the container to run the probe with. Point the orchestrator at /health/live : If you must have an in image HEALTHCHECK, base the runtime stage on a non chiseled image that includes wget — never re run the app binary as the probe command; that starts a second instance instead of checking the first. .dockerignore Docker Compose for Local Development Key .NET specific concerns — pass connection strings via environment, use depends on with health checks: Optimized Build with .slnx For solutions with multiple projects, restore only the necessary projects. Health Check Endpoint Anti patterns Don't Use SDK Image for Runtime Don't Copy Everything Before Restore Don't Run as Root Decision Guide Scenario Recommendation Web API container Multi stage build with aspnet runtime image Worker service Multi stage build with dotnet/runtime image Local development Docker Compose with service dependencies CI builds Multi stage build (self contained) Image size optimization Use Alpine variant + trimming for small images Health monitoring /health endpoint + orchestrator probe (K8s httpGet / Compose healthcheck) Secrets Environment variables or mounted secrets, never in image