DEV Community

Cover image for Try out .NET 6 inside your own development environment built with devcontainers, docker, and vscode
Oleksii Nikiforov
Oleksii Nikiforov

Posted on • Originally published at

Try out .NET 6 inside your own development environment built with devcontainers, docker, and vscode


In this blog post, I provide an example of how to organize/dockerize your personal development setup. Also, you may want to use one of my devcontainers to try .NET 6. Everything is baked inside the devcontainer, so you don't have to install SDK and other tooling on your host machine.


As you may know, .NET 6 Release Candidate 2 has been announced and it is very close to the final build of .NET 6 that will be shipped in November this year in time for .NET Conf 2021. It is the perfect time to start playing with .NET 6 and C# 10 and all of its goodness.

This is why I've created sandbox This is dotnet new webapi -minimal packed inside devcontainer. So, all you need to do is to get the source code and compile the devcontainer. You can do it by downloading via VSCode URL launcher or clone via git. I suggest you go straight to documentation for more details. My goal is to share my experience using devcontainers.

Here is how I do it:

git clone

devcontainer open ./devcontainer-for-dotnet6-demo
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Tip: You can open repository in VSCode code ./devcontainer-for-dotnet6-demo and after that, you will be prompted with a suggestion to reopen workspace in devcontainer (

πŸš€ Run dotnet run --project ./src/App/ and enjoy your coding.

Anatomy of devcontainers

When you generate configuration from VSCode, by default, it generates something like this:

$ tree -a 
└── .devcontainer
    β”œβ”€β”€ devcontainer.json
    β”œβ”€β”€ Dockerfile
    └── library-scripts
Enter fullscreen mode Exit fullscreen mode
# Dockerfile

Enter fullscreen mode Exit fullscreen mode
// .devcontainer/devcontainer.json

// For format details, see For config options, see the README at:
    "name": "",
    "build": {
        "dockerfile": "Dockerfile",
        "args": { 
            // Update 'VARIANT' to pick a .NET Core version: 2.1, 3.1, 5.0
            "VARIANT": "5.0"
    // Set *default* container specific settings.json values on container create.
    "settings": {},
    // Add the IDs of extensions you want installed when the container is created.
    "extensions": [
    "remoteUser": "vscode"
Enter fullscreen mode Exit fullscreen mode

A devcontainer.json file in your project tells VS Code how to access (or create) a development container with a well-defined tool and runtime stack. This container can be used to run an application or to separate tools, libraries, or runtimes needed for working with a codebase.

Everything you need is already added in the base docker image, but it is quite easy to extend it. You may want to pre-install some dependencies and tools in a custom Dockerfile.

πŸ’‘Tip: You are not limited to using devcontainers for .NET 6 project, actually, you can use them pretty much for everything. For example, I'm writing this blog post from devcontainer πŸ™‚.

Distribute devcontainers

Personally, I think it should be possible to easily explore the content of the devcontainer in order to change it on demand. This is why my go-to option is to create custom-tailored containers for each project based on some lightweight base images with shared tooling installed in them. For example, you might want to install something like:,,,,, etc. πŸ€“

Here you can find my devcontainer for .NET:

After that, you can install it directly from docker container registry by specifying "image" field inside devcontainer.json.

Minimum devcontainer looks like this:

    "name": ".NET 6 devcontainer",
    "image": "nikiforovall/devcontainers-dotnet:latest",
    "settings": {},
    "extensions": []
Enter fullscreen mode Exit fullscreen mode


You can also include your dotfiles repository to replicate your terminal experience (configurations, aliases, customizations, tools, etc.). See user settings for the "Remote - Containers" extension.

Basically, you want to configure the remote git repository as the source of dotfiles and tell vscode what to do upon installation. Here is my dotfile for devcontainers:

"settings": {
    "dotfiles.installCommand": "",
    "remote.containers.dotfiles.repository": "",
    "remote.containers.dotfiles.installCommand": "~/dotfiles/src/dev-container/boot/",
    "remote.containers.dotfiles.targetPath": "~/dotfiles",
Enter fullscreen mode Exit fullscreen mode

Anatomy - Summary

Name Description Responsibility
.devconatiner/devcontainer.json Workspace definition. Specify how to assemble devcontainer. Customize IDE (vscode) behavior.
.devconatiner/Dockerfile Image for docker container. Install dependencies and tools. Configure defaults.
dotfiles External versioned source of configuration for developer environment. Customize the way your terminal looks and feels and developer experience in general.


I've explained to you the main building blocks of devcontainers and shared some ideas regarding how you may want to organize your development setup. Hope you find it useful.


Discussion (0)