Best Practices for Production-ready .NET Docker Images
summary
Creates a production-ready .NET Docker image for a small Web API, starting from an 808 MB SDK image then switching to Alpine (drops to ~670 MB) and finally using multi-stage build plus publish trimmed ready-to-run single-file to reach ~80 MB. Uses explicit base tags (avoid latest), caches by copying csproj first, adds a healthcheck (installs curl), switches to a non-root user, and runs Docker Scan — Docker scan showed 60 issues then 0 after updating one vulnerable library and rebuilding.
AI-written summary · about
chapters (9)
- 0:00Introduction and setup
- 1:53Initial Dockerfile approach
- 3:40Analyzing image issues
- 7:25Optimizing base images
- 11:36Multi-stage build strategy
- 18:49Build context optimization
- 22:47Health checks and security
- 25:42Configuration and environment
- 27:32Running as a non-root user
related talks
51mDocker for .NET Developers
31mReal-world Docker images for .NET
20mCreating Production Ready Containers: What Devs Need to Know to Secure Their Containers
25m0 to production-ready: a best-practices process for Docker packaging
29mZero to production-ready: a best-practices process for Docker packaging
29m5 Security Best Practices For Production Ready Containers
27mLet's build our first C# API on Linux with VSCode and Docker
40m"Willy Wonka and the Secure Container Factory"
