A two-day hands-on workshop for .NET developers covering Docker fundamentals, multi-stage Dockerfiles, dotnet publish for container images, volume management, Docker CLI, and Aspire integration for local orchestration.
Understanding Docker for .NET Developers: Images, Publishing, and Aspire
Duration: 2 days
Hands-on workshop for .NET developers to build, run, and ship containerized applications with Docker. Learn how to author Dockerfiles, use dotnet publish for container images, customize outputs, manage volumes, operate with the Docker CLI, and see how Aspire models and configures these pieces.
Audience
- .NET developers new to containers
- Teams standardizing on Docker for local dev and deployment
Prerequisites
- Basic C#/.NET project experience
- Docker Desktop installed
Learning Goals
- Write and optimize Dockerfiles for .NET apps (build/publish/run stages)
- Use
dotnet publishto create images; customize publishing and container properties - Manage volumes for data/config and understand bind vs named volumes
- Operate core Docker CLI commands (build, run, ps, logs, exec, cp, prune)
- Use Aspire to model services, images, and configuration for local orchestration
Outline
- Docker fundamentals
- Images, layers, containers; registry basics
- Multi-stage builds for .NET (restore/build/publish)
- Dockerfiles for .NET
- Base images (SDK vs ASP.NET runtime vs distroless)
- Build args, env vars, entrypoints, healthchecks
- Trimming/AOT considerations for smaller images
dotnet publishfor containersdotnet publish -c Release -r <rid> --self-containedvs framework-dependentdotnet publish /p:PublishProfile=DefaultContainerand container properties- Customizing image name/tag, base image, container environment
- Volumes and data
- Bind mounts vs named volumes; mapping config/secrets; persistence
- Working with logs and data directories
- Docker CLI in practice
docker build,docker run,docker compose,docker ps/logs/exec/cp- Tagging, pushing/pulling; cleaning images/containers
- Aspire integration
- Modeling services and containers in AppHost
- Wiring environment variables, references, and health checks
- Viewing configuration and telemetry in the Aspire dashboard
- Deployment considerations
- Image optimization, caching, and layer hygiene
- Security basics: non-root, secrets, minimal base images
Hands-on Labs
- Author a multi-stage Dockerfile for a .NET web API and run it locally
- Use
dotnet publishto generate a container image; customize image name/tag and base image - Mount a named volume for data and inspect persistence across container restarts
- Use Docker CLI to build, run, inspect logs, and exec into a container
- Create an Aspire AppHost that runs the service container, sets environment variables, and exposes health checks
- View the running container and telemetry via the Aspire dashboard
Outcomes
- A working set of Dockerfiles and publish settings for .NET apps
- Confidence using Docker CLI and volumes for local development
- An Aspire model demonstrating container configuration, health, and telemetry