.NET 8.0 Development Container - Docker Setup & Usage Guide
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: 12 Dec 2025, using script mvc
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:
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!
2. Create the container
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 Applications with the Scripts (Recommended)
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 Docker.
Quick Start with Script Templates
This container includes 11 ready-to-use script templates for creating different types of .NET 8 applications. When you start the docker 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_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 |
Using the Scripts
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)
Run the App: 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/
─── ✦ ───
Creating Applications with .NET (Alternative)
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 in the previous command we specified 0.0.0.0 as the listening IP address, we can reach the web page on the host via localhost! So from the host, open a browser and navigate to: http://localhost:5000/
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
Build 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:
- 🐳 Docker Container Method (Recommended) - Build and run inside the container
- 🪟 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
These instructions will set up the task and launch items for VS Code for Docker(Linux) and Windows.
⚠️ Important: This six-step configuration procedure must be completed for each application you create.
1. Create .vscode folder in your project
Navigate to your application directory on Windows and create the configuration folder:
cd .\workspace\your-app mkdir .vscode
2. Copy template tasks.json
Copy the template file .\workspace.vscode-templates\tasks.json to the .vscode directory created in the previous step (.\workspace\your-app\.vscode)
3. Replace your-app with your actual application name in all paths in the copied tasks.json file.
4. Copy template launch_[script].json
Choose the launch template that matches your application type, then copy it to the .vscode directory created in step 1 and rename it to launch.json. Use launch_console.json for Console, Worker, and Library projects or launch_webapi.json for Web Apps and APIs. See the Available Script Templates table for the complete list of which script creates which application type.
Example copy command:
# For a console app: copy .\workspace\.vscode-templates\launch_console.json .\workspace\your-app\.vscode\launch.json
5. Replace your-app with your actual application name in all paths in the copied launch.json file.
6. Copy Directory.Build.prop
Copy the file: .\workspace.vscode-templates\Directory.Build.props to .\workspace\your-app\Directory.Build.props
This avoid ‘Duplicated errors messages’ when building for Docker and switch to Windows builds
- 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
- 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)
- 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
- 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)
Terminal → Run Build Task… → Select [your build task]
To Debug (F5)
Run → Start Debugging
To Watch
Terminal → Run 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 |
ms-dotnettools.vscodeintellicode-csharp |
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 |
jchannon.csharpextensions |
C# extensions for creating classes/interfaces |
kreativ-software.csharpextensions |
Additional 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
- Create network:
docker network create --subnet=172.40.0.0/24 dev1-net
- Create/Start container:
docker-compose -f compose_netcore_cont.yml up -d
Create Your First App
- Enter container:
docker exec -it net8-service-net-core8-img-1 bash
- 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
- 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.