Docker Template Stack .NET

A Docker container for .NET projects

View project on GitHub


.NET 8.0 Development Container - Docker Setup & Usage Guide

MIT License Commercial Services Available

Introduction

This guide walks you through setting up a Docker container with a .NET 8.0 development environment, including:

  • Pre-configured scripts for generating .NET project templates
  • tasks.json and launch.json for Visual Studio Code integration
  • All .NET 8.0 SDKs and runtimes

✅ Prerequisites
- Docker Desktop installed and running
- Repository is cloned to local machine
- External Docker network (configured in .env file)

Last successful tested: 24 Feb. 2026, using Cookiecutter MVC application type.


Setup

Follow these steps to set up your .NET 8.0 development container.

Create and Start the .NET Container

Navigate to the service directory:

Open PowerShell and navigate to the .\NET-Core-8\Net8-Service directory, then follow these steps:
🔹Tip: Rename the Net8-Service to a name that identifies your project to more easily identify it in Docker (Name). For this document we continue to use the name Net8-Service

1. Create the external network

Because this service uses an external network, you must ensure the network is created before creating the container. The network configuration is defined in the .env file. Create the network with this command:

 docker network create --subnet=172.40.0.0/24 dev1-net
 # This subnet is defined in `.env`

If you get an error message that the network already exists, you’re probably good to go!

Open a the .env and define a project IP address, that will be used in the compose_netcore_cont.yml file below

2. Create the container

First edit the above defined, IP address in the compose_netcore_cont.yml file then:

 docker-compose -f compose_netcore_cont.yml up -d
 docker-compose -f compose_netcore_cont.yml up -d --build --force-recreate
   

After that, you should have a Docker Desktop container called: net8-service-net-core8-img-1

3. To start a CLI in this container:

 docker exec -it net8-service-net-core8-img-1 bash 

This should open the Docker Container in the directory: /hostmount/workspace

Troubleshooting: Container is Not Starting

If the container fails to start or exits unexpectedly, check the logs:

# Get ID of container
docker ps           # Only returns running containers!
docker ps -a        # Includes stopped containers! (-a => all)
docker logs [ID]    # See what's going on

Verify .NET Installation

To verify the .NET SDK is installed correctly:

docker exec -it net8-service-net-core8-img-1 bash

Then inside the container:

dotnet --list-sdks
dotnet --list-runtimes

Creating Template Applications with the Scripts

Assuming that the Docker container has been successfully created and can be started with: docker exec -it net8-service-net-core8-img-1 bash we will show here how you can create a .NET 8.0 Template application with the different scripts that are provided within setup. In general there are three methods that will be described below:

  1. Using CookieCutter (easiest)
  2. Using Alternative Scripts
  3. Old School .NET.

This container includes the following ready-to-use Cookiecutter scripts for creating different types of .NET 8 applications with an advanced template, in contrast to the non-Cookiecutter scripts in the next section, these scripts should be started on the Windows host and can be found in the folder: ./project/workspace/.vscode-templates/[application type]/cookiecutter-dotnet-*. for example: ` ./project/workspace/.vscode-templates/mvc/cookiecutter-dotnet-mvc/`

That folder contains a README.md file with a few requirements and instruction to execute the script. But when you have installed Python and the Cookiecutter module it is as simple as executing the script: Create-mvc.ps1 with the Windows Power-Shell program After that, the solution and the newly created project will be created one folder up.

Available Cookiecutter Script(s)
Cookiecutter Script Creates Use For
vscode-templates\mvc\cookiecutter-dotnet-mvc\\create_mvc.sh MVC Web Application with advanced template See also side note: ‘Create Applications with Cookiecutter template’ in previous section

2. Use the Alternative Script()

This container includes a number of ready-to-use script templates for creating different types of .NET 8 applications. When you start the docker CLI container, you will automatically enter the host mount workspace (/hostmount/workspace) in your Bash Shell, if not, cd to that directory.

To access the scripts:
Execute these commands:

cd scripts                   # Navigate to script templates
ls -la                       # List all available scripts

The scripts will create the applications in directory: /hostmount/workspace

Available Script Templates
Script Creates Use For
create_console.sh Console Application CLI tools, utilities, learning
create_webapi.sh REST API Service Backend services, microservices
create_webapiaot.sh High-Performance API Ultra-fast APIs, cloud-native
create_mvc.sh MVC Web Application Traditional websites, admin panels
create_mvc.sh MVC Web Application Traditional websites, admin panels
create_webapp.sh Razor Pages App Content-heavy sites, blogs
create_blazorserver.sh Blazor Server App Interactive web apps (server-side)
create_blazorwasm.sh Blazor WebAssembly Client-side web apps (browser)
create_grpc.sh gRPC Service High-performance service communication
create_worker.sh Background Service long-running tasks, optional scheduled tasks (needs library)
create_classlib.sh Class Library (DLL) Reusable code, NuGet packages
create_xunit.sh Unit Test Project Testing your applications
Example: Scripts command

Basic Usage:

cd scripts
./create_console.sh                    # Creates 'app-console' in workspace
./create_webapi.sh my-api              # Creates 'my-api' in workspace  
./create_mvc.sh my-site /custom/path   # Creates 'my-site' in custom location

Script Parameters:

  • First parameter: Application name (optional, uses default if omitted)
  • Second parameter: Target directory (optional, defaults to: /hostmount/workspace)

3. Creating using old school method: .NET

If your preferred .NET template isn’t scripted, use the official .NET CLI in the Bash shell

ASP.NET Core Example:
For example to create an ASP.NET Core program (manually) in Docker, follow these steps:

Note: The resulting application will be created in the host mount folder: /hostmount/workspace

  • Create the app
    dotnet new web -n MyAspNetApp
    
  • Get the NuGet packages required
    cd MyAspNetApp
    dotnet restore
    
  • Run the app
    # Start the application server
    dotnet run --urls "http://0.0.0.0:5000" &
    
  • Access the app on the host Because we specified 0.0.0.0 as the listening IP address in the previous command, we can reach the web page on the host via localhost! Open a browser and navigate to: http://localhost:5000/

Run\test the created App in the Docker terminal

To run a Web based app:

  cd /hostmount/workspace/your-app  
  # for example
  cd /hostmount/workspace/app-mvc

  # Then run it:
  dotnet run --urls "http://0.0.0.0:5000" &
  

Why Applications are Created in Host Workspace

Why Applications are Created in Host Workspace

By default, all applications are created in /hostmount/workspace because:

  • Accessible from both Windows host and container
  • Persistent - survives container restarts
  • Easy editing - use Windows tools (VS Code, Visual Studio)
  • Source control - git repositories work seamlessly

Performance

Note: For CPU-intensive builds, you can copy projects to the container:

cp -r ./my-app /cworkspace/

─── ✦ ───

Create Applications with Cookiecutter template (Recommended)

Using Cookiecutter

Currently, there is one template available that creates an MVC application using Cookiecutter. his template provides a complete MVC application GUI. The application is created in the shared Windows Workspace folder, not inside the bash container.

To Install:

  • Enter the folder: .\workspace.vscode-templates\mvc\cookiecutter-dotnet-mvc\
  • Read the README.md file
    • Essentially, you just need to ensure Python and Cookiecutter are installed, then execute the PowerShell script.

    An example of the MVC application is displayed below:

MVC template with custom CSS components and usage examples

More Cookiecutter templates are planned for the future. The documentation will be updated accordingly to ensure consistency.

─── ✦ ───

Getting Container IP Address

If you need the IP address of the container to access the page via the host:

  • Get the name or ID of the container: docker ps
  • Execute this to get the IP:
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [container_id_or_name]
    # For this specific container:
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' net8-service-net-core8-img-1
      
    

Use the found IP to access the web page on the host. Start your browser on the host and navigate to: http://[found_IP]:5000


Use Template Projects with Visual Studio Code

This guide shows how to use Visual Studio Code to develop, build, and debug your .NET applications. Note that you’ll need to configure VS Code settings for each application you create.

We support two build methods:

  1. 🐳 Docker Container Method (Recommended) - Build and run inside the container
  2. 🪟 Windows Host Method - Build and run on your local Windows machine.
    Note : For some .Net application types (i.e. WPF) your are required to use this method!

💡 Our Recommendation:

  • Use Method 1 (Docker Container) for the most consistent, production-like environment. The Docker container was specifically designed for containerized .NET development and ensures your builds match the deployment environment.
  • When to use Method 2: Choose the Windows Host method if you need faster IntelliSense, prefer native Windows debugging, or want to avoid Docker overhead during rapid development cycles.

Important: Both methods share the same source code(on Windows):

  • Windows: ./workspace/your-app
  • Container: /hostmount/workspace

Configure Visual Code

This section describes how to configure Visual Studio Code running on the host to build and debug your application in Docker or Windows by setting up the VS Code Task.json and Launch.json items.

Prerequisites

  • For Docker\Linux (Recommended)
    • Docker container is running (net8-service-net-core8-img-1)
    • VS Code installed on Windows
    • Application created in /hostmount/workspace (see Creating Applications)
  • For Windows:
    • .NET 8.0 SDK installed on Windows (Download here)
    • VS Code installed on Windows
    • You have created an application, using one of the script commands, and created it in: .\workspace\your-app

Setup Tasks and Launch Configuration (skip for Cookiecutter script variants)

If your application was not created using a Cookiecutter template script, follow these steps to configure VS Code tasks and launch settings for Docker (Linux) and Windows. (If you used a Cookiecutter template, these steps are not needed, the required configuration files are generated automatically)

⚠️ Important: Complete this six-step configuration for each template application that you create with the none Cookiecutter script. Most scripts will copy the files for you, but you are still required to check the files and their content.

1. Check if the .vscode folder in your project exists
Navigate to your application directory on Windows and create the configuration folder if needed:

cd .\workspace\your-app\.vscode  # Should exist

2. Check if the template .\vscode\tasks.json exists
If it does not exists a Template can be found at .\workspace\.vscode-templates\tasks.json.

3. Replace your-app with your actual application name in all paths in the tasks.json file.

4. Check if the .vscode\launch.json exists
If it does not exists a template can be found at .\workspace\.vscode-templates\launch_[app-type].json.

5. Replace your-app with your actual application name in all paths in the copied ./vscode/launch.json file.

6. Check if the .\Directory.Build.prop exists
If it does not exists a template can be found at .\workspace\.vscode-templates\.
This avoids ‘Duplicated errors messages’ when building for Docker and switch to Windows builds.

  1. Optional. Use Scaffold tool to generate CRUD items There is a Task in VS Code ‘Scaffold CRUD: Controller + Views (no DB)’ this enable the genaration of CRUD Views. These additional steps are required if you want to use that.
    • Copy the Data directory in: .\workspace.src_extra_CRUD\Data to your root project. directory.
    • Add these references to you project file and make sure to rebuild
       <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
       <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
       <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
      

Use the VS Code Build & Debug (Docker & Windows)

When you have set up the Task and Launch configuration in the previous section, you can build and/or debug your application. In the Docker or Windows environment, use one of the Task or Launch profiles defined in the table below. Our recommended build method uses the Docker container SDK and tools.

Open Project in VS Code

  1. To develop and build in the Docker container recommended
    • Open VS Code.
    • CTRL-SHIFT-P
    • Type: Dev Containers:Attach to running container..
      • Select our container: net8-service-net-core8-img-1
      • Use the VS Code File → Open Folder command to open the container folder: /hostmount/workspace/your-app (e.g., /hostmount/workspace/app-mvc)
  2. To develop and build within Windows:
    • Open VS Code.
    • Open the Windows folder: .\workspace\your-app (e.g., .\workspace\app-mvc)
    • Installl at least these two extensions (For others see remark section, below):
      • ms-dotnettools.csharp -ms-dotnettools.csdevkit
  3. For both methods
    • Make sure the required VS Code extensions are installed in the container (see remark section below )
    • Use the Docker\Windows Task and Launchers defined in the table in combination with these instructions

To Build (Ctrl+Shift+B)
TerminalRun Build Task… → Select [your build task]

To Debug (F5)
RunStart Debugging

To Watch
TerminalRun Task… → Select [your watch task]

Task name Description Remark Build (Docker) Build your app using the Docker .NET SDK Publish (Docker) Publish your app via Docker build Watch (Docker) Automatically rebuilds on file changes Build (Windows) Build your app using the Windows .NET SDK Publish (Windows) Publish your app via Windows build Watch (Windows) Automatically rebuilds on file changes

VS Code Container extensions

The following extensions are required or recommended

Container Extension For
ms-dotnettools.csharp C# language support, IntelliSense, debugging required
ms-dotnettools.csdevkit C# Dev Kit for enhanced development experience required
GitHub.copilot-chat AI-assisted IntelliSense
redhat.vscode-yaml Editing YAML files (Docker Compose, CI/CD configs)
ms-azuretools.vscode-docker Docker file support
formulahendry.dotnet-test-explorer Test explorer for .NET
kreativ-software.csharpextensions C# productivity features

Performance Tip, slow Docker builds?

If builds are slow, copy your project to the container’s local filesystem for better I/O performance:

   docker exec -it net8-service-net-core8-img-1 bash
   cp -r /hostmount/workspace/your-app /cworkspace/
   

Then update all /hostmount/workspace/your-app paths in tasks.json and launch.json to /cworkspace/your-app



Appendix I - Quick Start Guide

🚀 Get up and running with .NET 8 development in under 5 minutes!

Prerequisites

  1. Create network:
    docker network create --subnet=172.40.0.0/24 dev1-net
    
  2. Create/Start container:
    docker-compose -f compose_netcore_cont.yml up -d
    

Create Your First App

  1. Enter container:
    docker exec -it net8-service-net-core8-img-1 bash
    
  2. Create an application (choose one):
    cd scripts
    ./create_console.sh my-first-app      # Console application
    ./create_webapi.sh my-api             # REST API
    ./create_mvc.sh my-website            # Web application
    ./create_blazorwasm.sh my-spa         # Single Page App
    
  3. Run your application:
    cd ../my-first-app    # or whatever you named it
    dotnet run
    

That’s It! 🎉

  • Your code is in: /hostmount/workspace/ (accessible from Windows)
  • Available scripts: 11 different .NET 8 project templates
  • Need help? Check the full documentation above

Quick Reference - All Available Templates

Command Creates Perfect For
create_console.sh Console App Learning, CLI tools
create_webapi.sh REST API Backend services
create_mvc.sh Web App Traditional websites
create_blazorwasm.sh SPA Modern web apps
create_classlib.sh Library Reusable code
create_xunit.sh Tests Testing your apps


License
This file is part of: Net-Core-Template Stack Copyright (c) 2025-2026 Nico Jan Eelhart.This repository is MIT licensed and free to use. For optional commercial support, customization, training, or long-term maintenance, see COMMERCIAL.md.


─── ✦ ───















Maintained by NicoJanE. Generated by GitHub Pages.