.NET
DevOps
Backend-Development

Docker for .NET Developers

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 publish to 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

  1. Docker fundamentals
    • Images, layers, containers; registry basics
    • Multi-stage builds for .NET (restore/build/publish)
  2. Dockerfiles for .NET
    • Base images (SDK vs ASP.NET runtime vs distroless)
    • Build args, env vars, entrypoints, healthchecks
    • Trimming/AOT considerations for smaller images
  3. dotnet publish for containers
    • dotnet publish -c Release -r <rid> --self-contained vs framework-dependent
    • dotnet publish /p:PublishProfile=DefaultContainer and container properties
    • Customizing image name/tag, base image, container environment
  4. Volumes and data
    • Bind mounts vs named volumes; mapping config/secrets; persistence
    • Working with logs and data directories
  5. Docker CLI in practice
    • docker build, docker run, docker compose, docker ps/logs/exec/cp
    • Tagging, pushing/pulling; cleaning images/containers
  6. Aspire integration
    • Modeling services and containers in AppHost
    • Wiring environment variables, references, and health checks
    • Viewing configuration and telemetry in the Aspire dashboard
  7. 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 publish to 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
An unhandled error has occurred. Reload 🗙