Lesson 10 of 40 DevOps Intermediate 50 min

Docker & Container Development

In this lesson, you will learn how Visual Studio 2026 helps you containerize applications with Docker, manage multi-container setups, and debug applications running inside containers.

← Back to Visual Studio 2026 Tutorial Home

What you will learn

Why this matters: Containers make applications easier to package, test, move, and deploy consistently across different environments.

Part 1: Adding Docker support

Visual Studio can generate Docker support directly from your project. This gives you a Dockerfile and related configuration so your application can be built and run inside a container.

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY *.csproj . RUN dotnet restore COPY . . RUN dotnet publish -c Release -o /app FROM mcr.microsoft.com/dotnet/aspnet:10.0 COPY --from=build /app . ENTRYPOINT ["dotnet", "MyApp.dll"]

A multi-stage Dockerfile helps keep the final image smaller by separating the build environment from the runtime environment.

Part 2: Docker Compose orchestration

Real applications often include more than one service, such as a web app, database, cache, or message broker. Docker Compose helps define and run those services together.

In Visual Studio, adding container orchestration support can generate a docker-compose.yml file and help launch the full environment more easily.

Example: A web API plus a SQL database is a common multi-container setup for local development.

Part 3: .NET Aspire integration

.NET Aspire focuses on cloud-native application development in .NET. Visual Studio 2026 makes it easier to start Aspire-based projects and inspect service interactions during development.

Aspire is especially useful when working with distributed applications and service-based architectures.

Part 4: Debugging in containers

One of the strengths of Visual Studio is that it can attach the debugger to a running container so the debugging experience stays familiar.

Benefit: This helps you test behavior closer to a real deployment setup instead of only on your local machine outside containers.

When to use each container tool

ToolBest used for
DockerfileDefining how one application image is built
Docker ComposeRunning multiple related services together
Container debuggingInvestigating issues in containerized apps
.NET AspireModern cloud-native and distributed .NET solutions

A practical container workflow

Step 1: Add Docker support to the project
Step 2: Review and understand the generated Dockerfile
Step 3: Add Docker Compose if your app needs supporting services
Step 4: Build and run the containerized app locally
Step 5: Debug inside the container when needed
Step 6: Refine images and settings before deployment

Best practices

Summary

In this lesson, you learned how Visual Studio 2026 supports Docker, multi-container development, Aspire-based workflows, and container debugging.

In the next lesson, you will explore .NET MAUI cross-platform application development.