Member-only story
.NET Development in Docker with Dev Containers
Now updated for .NET 6.0! — final code here.
In my last post, I configured a development environment for Ethereum development using Docker. This time around, I’ll do the same for .NET.
Building out a development environment in Docker has technically been possible for a while, but the ‘Remote Containers’ extension for Visual Studio Code has taken it to the next level. It’s at the point now where the tooling is mature enough to use on a real world project. In this post, I’ll scaffold a .NET API and build up some of the basic tooling that you would expect in a ‘normal’ dev environment, but I’ll run it all in a Docker container!
Before we get started, let’s recap some of the reasons for doing this in the first place:
- Consistency across all developer environments, which means an end to “well it works on my machine”.
- On boarding new developers is incredibly easy — they just pull the repo and all of the dev dependencies are already there.
- Updating every dev machine is also incredibly easy.
- The requirements to build and run the project on a dev machine are expressed as code, and move with the repo. (Extending the concept of ‘infrastructure as code’ to also include the dev environment)
- You don’t need to ‘pollute’ your machine with the dependencies for every single project you are working on.
- It is not mandatory. If any dev in the team has an aversion to Docker for whatever reason, they can simply opt out and not use the Docker functionality.
- The environment you are working in is tailored to the project you are working on.
Prerequisites
There’s a few prerequisites for this. I am assuming a decent understanding of Docker, VSCode, and Linux / WSL. Whatever machine you are using needs to have installed:
- Docker
- Visual Studio Code
- The ‘Remote Containers’ extension for VSCode
- If you are on Windows, I…