Revolutionizing Development Workflow with Dev Containers

Joseph Whiteaker
6 min readNov 12, 2023

--

As a developer, I’ve always been on the lookout for ways to make the setup process less of a hassle, especially when it comes to configuring new laptops or starting new projects. And let me tell you, Microsoft open sourced something a few years ago that’s a game changer: Dev Containers.

The Old Struggle with Setup

Remember the days of hours spent setting up your laptop? That’s what I initially wanted to address. The goal was simple: to make those long hours a thing of the past. Enter the concept of development containers.

The Docker Container Solution

With a development container, you can use practically any operating system, as long as Docker is installed. This container encapsulates your entire development workflow, seamlessly bridging the gap between local development and production consistency. But for some languages and tooling getting a local workflow with Docker can be a challenge. This forces developers to either choose between configuring their app development for development and could result in a worse developer experience or just not use containers for their apps running locally and only use containers for things such as databases, queues, cache, etc… which can quickly become a pain to work with locally at times when you have multiple different services running and communicating with each other.

The Pitfalls of Traditional Docker Workflows

Delving deeper into Docker and volumes, it becomes apparent that some workflows are impractical locally. They require complex setups like Docker Compose or Karpenter, pushing to local registries, and then using helm to push images from the registry to your local kubernetes cluster in which you then have to map a node port and create all of these config maps for your apps that are in the kubernetes cluster. This can feel like a Rube Goldberg machine of components, especially for workflows involving Node, Gradle, or .NET, where seeing simple changes can be time-consuming.

A Better Approach

The solution isn’t about changing the commands developers use daily. It’s about ensuring they work in consistent environments without altering their familiar workflows i.e. Dev Containers. With Dev Containers, a developer can open visual studio code, reopen the repo in a container that is specifically designed for development. All of the volume binding, ports, etc… are all handled for you. On top of all of this, dev containers will add the visual studio code extensions for you so that you can skip having to configure your plugins and all of that. You can start your dev container and get going using the cli commands that you already know to run your app. For example, I can open up a repo that is a dotnet solution, start the dev container up, and then run the dotnet cli commands that I already know and not have to deal with the problems that I described before.

For a simple showcase repo, visit my Github Repository, which demonstrates a workflow integrating .NET, PostgreSQL, Redis, and other services. This repository provides clear examples relevant to the topics discussed in this article. You can access it at josephaw1022/diving-deep-into-dev-containers (github.com).

The Dev Container File

Our Dev Container file is the heart of this new workflow. It outlines the specifics of the development environment, including the Docker Compose file, service configurations, and essential features like Git and PostgreSQL client. It even customizes Visual Studio Code settings and extensions to align with your development needs.

IDE Features: The Keys to Efficiency

One crucial aspect of enhancing productivity as a developer is developing a profound understanding of your Integrated Development Environment (IDE). In this context, Visual Studio Code (VS Code) emerges as a standout choice. Its open-source nature ensures that your investment in learning it is not subject to the whims of proprietary changes. This stability offers a sense of trust; the knowledge and skills you acquire today will remain relevant and unobstructed in the future. And this is where we will utilize task shortcuts for our development flow.

Streamlining Plugins In Visual Studio Code

The Dev Container in our environment significantly enhances productivity by automating the installation of Visual Studio Code plugins. Typically, developers spend considerable time manually selecting and installing necessary extensions for each project. This repetitive process can be both tedious and disruptive, as it diverts focus away from actual development tasks. With Dev Containers, this workflow is elegantly streamlined. When a developer opens a project, the Dev Container automatically configures Visual Studio Code with all the required extensions specific to that project’s needs. This automation not only saves valuable setup time but also ensures a consistent and optimized development environment across various projects. By eliminating the need for manual extension setup, developers can maintain their concentration and workflow, diving directly into the core development activities without unnecessary interruptions.

Streamlining Tasks with tasks.json In Visual Studio Code

The tasks.json file in our setup streamlines how we handle routine application and database operations. Traditionally, developers would have to switch between their code editor and a separate database management UI or delve into a command-line interface to execute common yet tedious database or cli commands. This process is not only time-consuming but also disrupts the development flow, as it requires shifting attention and context.

With our approach, tasks like database creation, migration, and backup are seamlessly integrated into the developer’s primary workspace. This integration is made possible through a simplified interface, where these operations are just a click away within the code editor. No more toggling between different tools or memorizing lengthy command-line instructions. By automating these processes in tasks.json, we not only save valuable time but also minimize the potential for errors that often accompany manual input.

This enhancement allows developers to remain in their coding environment, maintaining their focus and workflow continuity. It’s about making common tasks faster, more accessible, and less prone to human error, contributing significantly to overall productivity and ease of development.

Bottom Line

In conclusion, the advent of Dev Containers marks a significant leap forward in the world of software development. By integrating this technology into our workflows, we address not only the perennial challenges of setup and configuration but also elevate the overall developer experience. This approach harmonizes the intricacies of diverse development environments, offering a solution that is both elegant and practical.

The New Era of Development Efficiency

With Dev Containers, the days of tedious and time-consuming setup processes are behind us. This innovation allows developers to dive straight into coding, with all necessary tools and extensions readily at their disposal. The seamless integration with Visual Studio Code further enhances this experience, leveraging its robust features and stability to ensure a consistent, efficient, and enjoyable development journey.

A Community-Driven Path Forward

Moreover, the open-source nature of tools like Visual Studio Code and the collaborative approach to developing Dev Containers underscore a broader shift in the software development world. We are moving towards a more community-driven, transparent, and inclusive future. This shift not only empowers individual developers but also fosters a culture of sharing, learning, and continuous improvement across the industry. Proprietary solutions to developing applications are a thing of the past.

The Bigger Picture

Ultimately, the journey with Dev Containers is more than just about individual convenience or efficiency. It’s about shaping a development ecosystem that is adaptable, resilient, and forward-thinking. It empowers developers to focus on what truly matters — innovation and creativity, leaving the complexities of environment setup and configuration as a thing of the past.

--

--